This is my solution to the challenge. It is really simple, but it seems that the wordlist and proper names list is not on my computer?? Can somebody explain why this does not work out?
[code]int main(int argc, const char * argv[])
{
@autoreleasepool {
// Read in the strings from the files
NSString *nameString = [NSString stringWithContentsOfFile:@"usr/share/dict/propernames" encoding:NSUTF8StringEncoding error:NULL];
NSString *wordString = [NSString stringWithContentsOfFile:@"usr/share/dict/words" encoding:NSUTF8StringEncoding error:NULL];
//Break the files into arrays
NSArray *names = [nameString componentsSeparatedByString:@"\n"];
NSArray *words = [wordString componentsSeparatedByString:@"\n"];
//Iterate through the arrays
for ( NSString *n in names) {
for (NSString *w in words) {
NSRange r = [n rangeOfString:w options:NSCaseInsensitiveSearch];
//Was it found?
if (r.location) {
NSLog(@"%@ AND %@\n", n, w);
}
}
}
}
return 0;
}
[/code]