CoreData唯一约束在Xcode中消失 [英] CoreData unique constraints disappears in Xcode

查看:76
本文介绍了CoreData唯一约束在Xcode中消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在实体中的属性 photoID 上添加唯一约束PhotoUpload

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

我点击约束并添加 photoID

当我导航到另一个文件并返回到 xcdatamodeld 文件时,约束不存在。它会被自动删除。

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.


  • 我尝试删除 xcdatamodeld 文件并重新创建它,但是仍然存在相同的问题。

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

Xcode-7.3.1

Xcode - 7.3.1

推荐答案

我认为这是一个错误Xcode。如果更改模型以添加(或修改或移除)约束,则即使屏幕正确显示了更改,基础模型文件也不会更新。为了克服它,在添加唯一性约束的同时更改模型的另一个元素。保存模型。然后将其他元素改回并再次保存。

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.

这篇关于CoreData唯一约束在Xcode中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆