user1046037
user1046037

Reputation: 17715

CoreData unique constraints disappears in Xcode

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:

Screenshot:

enter image description here

Versions:

Xcode - 7.3.1

Upvotes: 2

Views: 393

Answers (1)

pbasdf
pbasdf

Reputation: 21536

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.

Upvotes: 4

Related Questions