MagicalRecord relationship mapping duplicates objects despite primary keys

北城余情 提交于 2019-12-03 08:09:38

I managed to solve this a while back.

What I did was add relatedByAttribute in the User Info dictionary for the children relationship AND for the Child entity as well.

So click on the relationship and set relatedByAttribute to childId (in my example above) and also click on the Child entity on the left and for this also set relatedByAttribute to childId in the User Info dictionary for the entity itself.

This allows Magical Record to correctly map using existing objects or create new ones if needed - granted that the ID attribute is 100% unique!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!