Solution to Challenge 2 (faster search)

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // Read in a file as a huge string (ignoring the possibility of an error)
        NSString *nameString =
        [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames"
        // Read in a file containing regular words
        NSString *wordString =
        [NSString stringWithContentsOfFile:@"/usr/share/dict/words"
        // Break both into an array of strings
        NSArray *names = [nameString componentsSeparatedByString:@"\n"];
        NSArray *words = [wordString componentsSeparatedByString:@"\n"];
        // This will help to keep a reference to the index of words NSArray
        NSInteger index = 0;
        // Go through both array one string at a time
        // The number of items with in words NSArray is needed for a regular for loop
        NSInteger wordsCount = [words count];
        for (NSString *n in names) {
            // Look for a matching string in words in a case-insensitive manner
            // Start from the last search location in words NSArray
            for (long i = index; i < wordsCount; i++) {
               // BOOL match = [n isEqualTo:w];
                NSComparisonResult match = [n compare:words[i] options:NSCaseInsensitiveSearch];
                // Print out the match that was found
                if (match == NSOrderedSame && ![n isEqualToString:@""])
                    NSLog(@"%@ is also a regular word.", n);
                    // Remember the location of last match with in the words NSArray
                    index = i + 1;
                    // Stop the search since a match is found
    return 0;