On 2009 Feb 25, at 16:39, Dave Fernandes wrote:

Well, as I mentioned I have stuck with KVO. I don't see why you need to remove observers when turning into a fault. You only need to remove observers before the object disappears.

Ah, good point. I was using -didTurnIntoFault since -[NSManagedObject dealloc] is unreliable and not recommended for overriding.

I have created my own NSManagedObject subclass as you have, and I have a -removeSelfFromObserveredObjects method in that subclass that I call before deallocating the MOC. (Fetch all objects from MOC and call this method, if it exists.) ...it's not pretty, but it works.

Note that a fetch will not return deleted objects that might still be on the undo stack, so I also call removeSelfFromObserveredObjects from the managed object's dealloc method.

Oooo, dealloc is not recommended for overriding.

(You will have to check that you do not call removeSelfFromObserveredObjects twice.) As I said, it's not pretty, but it works.

Wow, that ^is^ ugly.  I'll think about it.

If anyone has a better way, I'd love to hear it!

Ditto from me.

Thanks, Dave.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to