CoreData 防止删除默认值
我的基于 coredata 文档的应用程序中有一个实体。
我有一些在为该实体创建新文档时创建的默认值。
我需要能够允许用户从该列表中添加和删除(很容易完成),但阻止用户删除默认值(找不到答案)。
感谢您的回复,在这种情况下这是一个不错的选择,我想我会使用它。
我想知道是否有人知道一个人如何验证删除......因此,如果一个人单击删除按钮,它将经历一些逻辑(复杂或简单,取决于应用程序),然后忽略单击或实际上删除该对象。
我查看了 validateForDelete: 方法,但是关于它的文档很少,我不确定这是否是该方法的预期用途。
I have an entity in my coredata document based application.
I have certain default values that get created when a new document is created for that entity.
I need to be able to allow users to add and remove from that list (easily done), but prevent users from deleting the default values (cant find the answer).
Thanks for your response, that is a good option in this case I think I will use it.
I was wondering though if anyone knows how a person can VALIDATE a delete.... so if a person clicks on the delete button, it will go through some logic (complex or simple, depending on the application) then either ignore the click or actually delete the object.
I've looked at the method validateForDelete: but there is very little documentation on it and i'm not sure if this is the intended use of the method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以向实体添加一个布尔属性来指示某个值是否为默认值。如果当前选择的值是默认值,您可以使用
enabled
绑定停用删除按钮。You could add a boolean attribute to your entity that indicates whether or not a value is a default. You could then deactivate the delete button if the currently selected value is a default, using the
enabled
binding.