nspredicate questions
I tried applying NSPredicate
with core data, but how to apply it with NSMutableArray
of classes?
I mean: I have NSMutableArray
contai开发者_运维技巧ning objects of class that have fields. How do I select the object with name test for example?
Another question: can I use NSPredicate
to simulate the following SQL statement?
where field1 in ('A', 'B')
How do I select the object with name test
NSPredicate *p = [NSPredicate predicateWithFormat:@"name = %@", @"test"];
NSArray *filtered = [arrayOfObjects filteredArrayUsingPredicate:p];
can I use
NSPredicate
to simulate the following SQL statement?
Yep!
NSPredicate *p = [NSPredicate predicateWithFormat:@"field1 IN %@", [NSArray arrayWithObjects:@"A", @"B", nil]];
NSArray *filtered = [arrayOfObjects filteredArrayUsingPredicate:p];
精彩评论