Padin215
Padin215

Reputation: 7484

NSFetchedResultController for an Entity and its relationships

I have an Entity Person. Person has three relationships to Entity ObjectA, ObjectB, and ObjectC.

Can I use an NSFetchedResultController to sort them by type? So section 0 would be ObjectA's, section 1 would be ObjectB's, and section 3 would be ObjectC's? And further, can i sort them by name?

Or do I use 3 different datasources (either load them into an array or 3 different NSFetchResultController's)?

Upvotes: 1

Views: 71

Answers (1)

ejdyksen
ejdyksen

Reputation: 1509

An NSFetchedResultController can only fetch one entity type at a time, so assuming ObjectA, ObjectB, and ObjectC are different entity types, then you'll need three NSFRCs.

If they are three different entity types, you might consider putting them under an abstract entity. Then you could create one NSFRC for that type (example here).

Upvotes: 1

Related Questions