Core Data 的删除对象是否从托管对象上下文中删除该对象?
我对自定义对多关系访问器很好奇。访问器将从另一个对象中删除相关对象是有道理的。但我想知道您是否希望将对象从托管对象上下文(以及随后的后台存储)中完全删除,是否还需要从托管对象上下文中删除该对象然后保存它?
感谢您的帮助!
抢
I am curious about the Custom To-Many Relation Accessors. It makes sense that the accessor will remove related object from the other object. But I was wondering if you wanted the object completely removed from the managed object context (and subsequently the back store), do you also need to delete the object from the Managed Object Context and then save it?
Thanks for any help!
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
罗布,
删除只会影响关系。您必须删除该对象才能将其从 MOC 和后备存储中删除。
IOW,这些是根本不同的操作。
安德鲁
Rob,
Removing just affects the relationship. You must delete the object to remove it from the MOC and the backing store.
IOW, these are fundamentally different operations.
Andrew
请注意,有一种称为“删除传播”的东西,当对象从关系中删除时,它可能会导致对象被删除。参见 核心数据编程指南。
Be aware that there's something called delete propagation which may cause objects to get deleted when they're removed from a relationship. C.f. Relationship Delete Rules under Relationships and Fetched Properties in the Core Data Programming Guide.