No output!


#1

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]


#2

[quote]
but it seems that the wordlist and proper names list is not on my computer??

// 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]; ... [/quote]
You have missed the first character in each file path. What did the book ask you to type in?


#3

Thank you! Yes, a forward slash. Definately worth an hour of pondering :open_mouth: