Skip to content

Instantly share code, notes, and snippets.

@CocoaPriest
Created September 26, 2011 00:10
Show Gist options
  • Save CocoaPriest/1241350 to your computer and use it in GitHub Desktop.
Save CocoaPriest/1241350 to your computer and use it in GitHub Desktop.
фильтрация
// ------------- с предикатом
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"groupID >= %d", 1];
NSArray *filteredArray = [myArray filteredArrayUsingPredicate:predicate];
// ------------- с блоками
NSIndexSet *filteredIndexes = [myArray indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
if(obj.groupID >= 1)
return YES;
return NO;
}];
NSArray *filteredArray = [myArray objectsAtIndexes:filteredIndexes];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment