有没有Core Data回调方法? [英] Are there Core Data call back methods?
问题描述
我想知道在核心数据实体中发生某些事情时是否有任何特殊的方法。
I am wondering if there is any special way to take action when something happens in a core data entity.
这里是我的意思。我有一个文件名作为一个属性存储在核心数据实体中。
Here what I mean in the present case. I have a file name stored as an attribute in a core data entity.
当应用程序运行时,可能发生具有此文件名的项目从核心中删除数据。
As the app is running, it can happen that the item with this file name is removed from core data.
在这种情况下,我想要发生的是文件从文件系统中删除。
这是我的问题:
我需要编写我自己的代码来执行此删除吗?
或者有一种方法,我可以使用,所以删除程序会自动启动时,从核心数据中删除项目?
In that case what I want to happen is that the file gets removed from the file system. And this is my question: Do I need to write my own code to perform this removal? Or is there a way, that I could use, so a removal procedure would be fired automatically when the item is removed from core data?
换句话说,有一个回调方法如:
In other words, is there a call back method like:
-(void) objectWillBeRemoved:((NSManagedObject*))object
或:
-(void) objectHasBeenRemoved:((NSManagedObject*))object
感谢任何相关提示。 / p>
Thanks for any relevant tip.
推荐答案
查看 NSManagedObjectContextObjectsDidChangeNotification
。
您可以在 NSManagedObjectContext类参考。
这篇关于有没有Core Data回调方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!