November 2013
Beginner
325 pages
9h 47m
English
This challenge is more challenging. Read through the following program, which finds common proper names that contain two adjacent A’s.
#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" encoding:NSUTF8StringEncoding error:NULL]; // Break it into an array of strings NSArray *names = [nameString componentsSeparatedByString:@"\n"]; // Go through the array one string at a time for (NSString *n in names) { // Look for the string "aa" in a case-insensitive manner NSRange r = [n rangeOfString:@"AA" options:NSCaseInsensitiveSearch]; ...Read now
Unlock full access