One Quickie


Processing every line in a string (NSString->NSArray)
Say you got a string that's composed of one interesting data item per line, like /usr/share/dict/words or from a script, and you want to process them. In this case turning a bunch of strings into floats:
    NSMutableArray *altitudes = [NSMutableArray array];
    NSString *altitudeString = [self altitudeStringFromGoogle: coords];

    [altitudeString enumerateLinesUsingBlock: ^(NSString *line, BOOL *stop) {
            float value = [line floatValue];
            [altitudes addObject: [NSNumber numberWithFloat: value]];
        }];



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com