Janub
Janub

Reputation: 1594

using relationship with Core Data On iOS

I have 2 entries
1. category (main one)
2. info

the relationship is 1 to many , for every category there is several info's

after i added the several info classes to each categoty i want to get each category relationship list in the detailsviewcontroller

I created a temp class in the details view the contain the selected category how do i get access to the list of INFO'S ??

Upvotes: 2

Views: 197

Answers (2)

Bek
Bek

Reputation: 2226

Without seeing your code or model classes, I can't give you the exact answer. But when you made your model, you probably named your relationship something like "infosForCategory". When you generated the model it made a NSMutableSet for that 1-to-many relationship. In that case, you can access the list of infos with:

NSMutableSet *myInfos = myCategory.infosForCategory;

Upvotes: 1

Mark Adams
Mark Adams

Reputation: 30846

I'm not exactly sure what you're asking but it sounds like you already have an instance of Category and you want to retrieve all the related instances of Info. In that case, Category should have an automatically generated info property that is of the NSSet type. That set will contain all of the related Info objects.

Upvotes: 1

Related Questions