Definitely stuck on this one the longest so far. Now I’m finally done when comparing solutions I really thought it was worth posting mine.
I chose to use BOOL values to check equality.
One problem I do seem to have is the program doesn’t seem to end, have I missed something? Is it getting itself stuck somewhere?
[code]//
// main.m
// InterestingNames
//
// Created by Dan Chambers on 29/01/2015.
// Copyright © 2015 Big Nerd Ranch. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSString *wordString = [NSString stringWithContentsOfFile:@"/usr/share/dict/words"
encoding:NSUTF8StringEncoding
error:NULL];
NSArray *words = [wordString componentsSeparatedByString:@"\n"];
NSString *nameString = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames"
encoding:NSUTF8StringEncoding
error:NULL];
NSArray *names = [nameString componentsSeparatedByString:@"\n"];
for (NSString *n in names) {
for (NSString *w in words ) {
BOOL match = [n isCaseInsensitiveLike:w];
if (match == YES) {
BOOL caseCheck = [n isEqualTo:w];
if (caseCheck == NO) {
NSLog(@"I have found the normal word %@ which matches %@", w, n);
}
}
}
}
NSLog(@"That concludes the comparison");
}
return 0;
}[/code]