开发者

Creating Predicate to Test the Number of Relationship

Say I have a Business object in core data. The Business object may or may not have phones.

I want to create an NSPredicate object where only Businesses with Phones would work.

How would I do so?

    NSPredicate * thePredicate5= [NSPredicate predicateWithFormat: @"Ph开发者_如何学JAVAones.count > 0"];

or what?


NSPredicate * thePredicate5= [NSPredicate predicateWithFormat:@"NONE Phones == nil"];

or

NSPredicate * thePredicate5= [NSPredicate predicateWithFormat:@"ANY Phones != nil"];

I didn't know the answer when I first read your question but it caught my attention. I read the documentation and did some experimenting on one of my projects (iphone app that uses Core Data and sqlite) and the attached code seems to do what you wanted, but I cannot guarantee that it is the correct solution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜