开发者

Core data query on a NSSet of NSSet

开发者 https://www.devze.com 2022-12-22 07:10 出处:网络
I\'m struggling with core data... I don\'t understand some things so if someone could help me, I would be very grateful!

I'm struggling with core data... I don't understand some things so if someone could help me, I would be very grateful! I have an entity (Recipe) with a relationship to-many with another one (Meal). I would like to select all the recipes which have no connection with a meal... so I've tried:

Code:

[myRecipes filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"meal=%@", nil]];

But it doesn't work... it crashes.

When I look at the SQL database under re开发者_JAVA技巧cipe I don't see meal (I think it's because it's a to-many relationship). How can I make it?

Thanks


According to this question

To test for an empty relationship you should compare the count of the to-many key to zero.

For example,

[NSPredicate predicateWithFormat:@"meal.@count == 0"]
0

精彩评论

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