开发者

How to add observers to an NSManagedObject?

What is the preferred approach to registering observers on an NSManagedObject (since Core Data "'owns' the lifecycle" of managed objects)?

Am I correct that the way to do this is to listen for NSManagedO开发者_StackOverflow中文版bjectContextObjectsDidChange-Notification and call addObserver:... for NSInsertedObjectsKey and removeObserver:... for NSDeletedObjectsKey?


In order to observe MOs throughout their lifecycles, add observers when they come into existence, with awakeFromInsert and awakeFromFetch.


Yeah, you're correct. Observing the MOs directly will lead to trouble, for reasons you have already posted in your question (within the parentheses).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜