8vius
8vius

Reputation: 5836

Fetching data from CoreData with multiple Entities

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

Upvotes: 0

Views: 505

Answers (1)

Paul Tiarks
Paul Tiarks

Reputation: 1921

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.

Upvotes: 1

Related Questions