• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Observing Managed Object Changes. Was: Strange ... behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Observing Managed Object Changes. Was: Strange ... behavior


  • Subject: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 25 Feb 2009 16:52:02 -0800


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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Observing Managed Object Changes. Was: Strange ... behavior
      • From: Dave Fernandes <email@hidden>
References: 
 >Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Karolis Ramanauskas <email@hidden>)
 >Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Jerry Krinock <email@hidden>)
 >Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior (From: Dave Fernandes <email@hidden>)
 >Observing Managed Object Changes. Was: Strange ... behavior (From: Jerry Krinock <email@hidden>)
 >Re: Observing Managed Object Changes. Was: Strange ... behavior (From: Dave Fernandes <email@hidden>)

  • Prev by Date: renaming a file with special/reserved characters in name
  • Next by Date: NSURL behaviour at odds with documentation
  • Previous by thread: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Next by thread: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Index(es):
    • Date
    • Thread