NSPredicate のサブクラスを使用できますNSCompoundPredicate
NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:
@[[NSPredicate predicateWithFormat:@"SELF.name CONTAINS[cd] %@", aString],
[NSPredicate predicateWithFormat:@"SELF.city CONTAINS[cd] %@", aString],
[NSPredicate predicateWithFormat:@"SELF.state CONTAINS[cd] %@", aString]
]
];
しかし
«2 つ以上 — for を使用» Edsger W. Dijkstra
«または列挙型» vikingosegundo
NSString *aString =@"Ney York";
NSMutableArray *predicates = [@[] mutableCopy];
[@[@"name", @"city", @"state"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSString *format = [NSString stringWithFormat:@"SELF.%@ CONTAINS[cd] %%@", obj];
[predicates addObject:[NSPredicate predicateWithFormat:format, aString]];
}];
NSPredicate *predicate = [NSCompoundPredicate orPredicateWithSubpredicates:predicates];