I m having some trouble with a recursive relationship in core data. I ve got a managed object called a "SearchCategory", and that category can have "Categories" and it can also have a "Category." In the managed object modeler, I ve got two relationships set up on the SearchCategory entity, and both point back to the SearchCategory entity - one is named "Categories" and is a to-many relationship. The other is "Category", is not a to-many, and is the inverse of "Categories."
In my code I m using "setCategoriesObject" to add categories to a searchcategory, which seems to be working. However, when I say [mySearchCategory setCategory:aParentCategory]
, where mySearchCategory
would be a child category of aParentCategory
, it doesn t seem to want take in memory. If I run the above code, then [managedobjectcontext save:&err]
, it actually saves the primary key of the parent category to the "Category" field of the child category in the database, but Core Data doesn t synthesize this relationship at run time, so [mySearchCategory Category]
returns nil. Any thoughts here?