Reputation: 4973
If I have 'Category' and 'Asset' entities and they have an inverse many-to-many relationship called 'assets' and 'categories' respectively, how would I add an additional entity instance of either Category or Asset into the existing relationship set?
Do I get the existing set and turn it into a mutableSet add the new entity and write it back to the db?
That doesn't seem like a great way, i guess i need the equivalent to addObject: in my Managed Object Entity class.
Any help would be appreciated.
Thank You.
Upvotes: 0
Views: 95
Reputation: 539685
If you have created the NSManagedObject
subclass files
"Category.h/.m" and "Asset.h/.m" then you can simply add an asset to a category with
[category addAssetsObject:asset];
or add a category to an asset with
[asset addCategoriesObject:category];
Upvotes: 1