开发者

Fetching data from CoreData with multiple Entities

开发者 https://www.devze.com 2023-03-18 07:49 出处:网络
I have a data model that has 2 entities Person and Photo, they have have Attributes named name how can I be sure when using a NSPredicate that I will fetch or evaluate information from the correct ent

I have a data model that has 2 entities Person and Photo, they have have Attributes named name how can I be sure when using a NSPredicate that I will fetch or evaluate information from the correct entity if I'm looking by name?

开发者_如何学编程

This would be my current NSPredicate but I'm really unsure on the issue:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", [currItem objectForKey:@"user"]];


You would set the appropriate entity on the NSFetchRequest that you're using to fetch the entities. The name field would correspond to the name field on whatever entity you set.

0

精彩评论

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