What is the best way to update or add data if relationships
are chained.
I have my coredata
designed like this:
I have 3 Entities
1) User
To_Many
Category2) Category
To_Many
Item3) Item
To_One
Category
User
is required before adding a Category
, and Category
is required before adding an Item
答案 0 :(得分:1)
简单。只需设置一对一关系,相应的反向关系将由Core Data自动设置。
newItem.category = category
category.user = user
根据最佳做法,我将笨拙的属性名称itemCategory
,categoryUser
,categoryInUser
重命名为category
,user
,{分别为{1}}。