开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜