Core data insert new data with existing relationship

前端 未结 1 1198
无人共我
无人共我 2021-01-28 04:44

I got problem with core data, I had a table that exactly look like this

User (relationship with) Rack (relationship with) RackItem

How should I insert new object

相关标签:
1条回答
  • 2021-01-28 04:47

    This seems a little confusing ... first of all you should have of course as NeverBe said a to-many relationship between Rack and RackItem

    Then it seems to me that you're having a conceptual issue here. If you want to insert a new object related to the same Rack than a previous RackItem ... just fetch that Rack Object and insert your new RackItem by setting it's rack property to the Rack you just fetched.

    You really should keep it simple or you're just gonna have a lot of Coredata inconstancy issues Hope that this will help

    0 讨论(0)
提交回复
热议问题