CoreData unique constraints disappears in Xcode

我的梦境 提交于 2020-01-11 11:29:47

问题


What I want to do:

Add a unique constraint on the attribute photoID in the entity PhotoUpload.

Problem:

I tap on constraints and add photoID.

When I navigate to a different file and come back to the xcdatamodeld file, the constraint is not present. It is automatically removed.

And so the unique constraint is not working.

What I have done so far:

  • I have tried deleting the xcdatamodeld file and re-created it, but the same problem persists.

Screenshot:

Versions:

Xcode - 7.3.1


回答1:


I believe this to be a bug in Xcode. If you change the model to add (or amend or remove) a constraint, the underlying model file is not updated, even though the screen shows the changes correctly. To overcome it, change another element of the model at the same time as adding the uniqueness constraint. Save the model. Then change the other element back and save again.



来源:https://stackoverflow.com/questions/38496346/coredata-unique-constraints-disappears-in-xcode

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