CoreData阻止删除默认值 [英] CoreData prevent delete of defaults

查看:118
本文介绍了CoreData阻止删除默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于coredata文档的应用程序中有一个实体。

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.

我看过方法validateForDelete:但有很少的文档,

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.

推荐答案

您可以向您的实体添加一个布尔属性,无论值是否为默认值。如果当前选择的值是默认值,则可以使用启用绑定来取消激活删除按钮。

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.

这篇关于CoreData阻止删除默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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