If you want to become a super fantasy with the blocks presented in Snow Leopard, you can do:
- (BOOL (^)(id obj, NSUInteger idx, BOOL *stop))blockTestingForTitle:(NSString*)theName {
return [[^(id obj, NSUInteger idx, BOOL *stop) {
if ([[obj objectForKey:@"title"] isEqualToString:theName]) {
*stop = YES;
return YES;
}
return NO;
} copy] autorelease];
}
and then whenever you want to find a dictionary index in an array:
[array indexOfObjectPassingTest:[self blockTestingForTitle:@"Salon One"]]
source
share