In my project there is a managed object called "Group".
This object itself can contain child group objects.
How do I solve this situation in CoreData and in the FetchedResultsController?
My first shot:
http://i46.tinypic.com/zvonpd.png
Thanks, Dan
I would make two separate relationships that are inverses of each other.
Group has a to-many relationship with Group named "children", Group also has a to-many relationship with Group named "parents" and they are inverses of each other.
Or, if your data model only calls for one parent: Group has a to-many relationship with Group named "children", Group also has a to-one relationship with Group named "parent" and they are inverses of each other.
It looks correct. Usually you term the other entities children instead of parents but that is just a matter of style and convention.
You would fetch the child/parent relationship just as you would any other attribute. The only gotcha is that each relationship attribute is returned as a NSSet so you have to find the child you want inside of the set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.