August 2011
Intermediate to advanced
552 pages
23h 48m
English
Blocks can also access their enclosing scope. Say you wanted to print out each of the words that contains “badger.” You can use a variation of the previous code, using -enumerateObjectsUsingBlock:
[array enumerateObjectsUsingBlock: ^(id object, NSUInteger index, BOOL *stop) { NSRange match = [object rangeOfString: @"badger"]; if (match.location != NSNotFound) { NSLog (@"found a '%@' : %@", @"badger", object); } }]; ...Read now
Unlock full access