Filtragem NSArray fácil

Como ao filtrar consultas de dados centrais, o NSPredicate pode ser usado em matrizes:

NSArray *robocatApps = @[ @"Thermo", @"Outside", @"101st Airborne", @"Ultraviolet", @"Treasure Trouble", @"Dunk" ];

NSArray *shortNameApps = [robocatApps filteredArrayUsingPredicate:[NSPredicate predicateWithFormat: @"self.length <= 7"]];

NSArray *longNameApps = [robocatApps filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id obj, NSDictionary *bindings){
return ([obj length] > 7);
}]];

NSLog(@"short name apps: %@", shortNameApps);
// Thermo, Outside, Dunk

NSLog(@"long name apps: %@", longNameApps);
// "101st Airborne", Ultraviolet, "Treasure Trouble"