Challnge 2 - Did I or didn't I?


#1

I swear I did this right. It even tells me it succeeded. But I’m not getting any Messages in the debugger.

So are there no similarities? Did I mess up the log statement? Is there another part of my code that I’ve screwed up and am just not catching?

I just need another set of eyes on this. Please!

I’ve checked it against other solutions and I eerily typed almost the same code as another person. My for statement was different that was all, so I changed it to look like his, which a replier said looked correct, still nothing.

I had:

[code]// Go through the 2 arrays
for (NSString *n in names)
for (NSString *w in words) {

            NSString *n = @"nameString";
            NSString *w = @"wordString";
            
            if ([n caseInsensitiveCompare:w] == NSOrderedSame) {
                NSLog(@"%@ & %@ are the same!", n, w);
            }
        }[/code]

Where as he had:

[code]// Go through the 2 arrays
for (NSString *n in names) {
for (NSString *w in words) {

            NSString *n = @"nameString";
            NSString *w = @"wordString";
            
            if ([n caseInsensitiveCompare:w] == NSOrderedSame) {
                NSLog(@"%@ & %@ are the same!", n, w);
            }
        }
    }[/code]

Anyways here is my complete code. Please help! Please!

[code]#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    
    // Read in proper name list as a huge string (ignoring the possibility of an error)
    NSString *nameString
    = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames"
                                encoding:NSUTF8StringEncoding
                                   error:NULL];

    // Read in word list as a huge string (ignoring the possibility of an error)
    NSString *wordString
    = [NSString stringWithContentsOfFile:@"file/usr/share/dict/words"
                                encoding:NSUTF8StringEncoding
                                   error:NULL];
    
    // Break proper names into an array of strings
    NSArray *names = [nameString componentsSeparatedByString:@"\n"];
    
    // Break words into an array of strings
    NSArray *words = [wordString componentsSeparatedByString:@"\n"];
    
    // Go through the 2 arrays
    for (NSString *n in names) {
        for (NSString *w in words) {
            
            NSString *n = @"nameString";
            NSString *w = @"wordString";
            
            if ([n caseInsensitiveCompare:w] == NSOrderedSame) {
                NSLog(@"%@ & %@ are the same!", n, w);
            }
        }
    }
}
return 0;

}[/code]