• 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: Removing object as observer in -willTurnIntoFault
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing object as observer in -willTurnIntoFault


  • Subject: Re: Removing object as observer in -willTurnIntoFault
  • From: Dado Colussi <email@hidden>
  • Date: Sat, 29 Mar 2014 13:44:40 -0500

If you have undo/redo going on, then restart observing in
awakeFromSnapshotEvents when NSSnapshotEventUndoDeletion flag is present.
Check out the other flags, too.

/Dado


On 29 March 2014 13:13, Jerry Krinock <email@hidden> wrote:

> A subclass of NSManagedObject needs to observe some stuff.
>
> So, in -awakeFromFetch and -awakeFromInsert, I invoke an
> -initializeObservers method which adds observers like this...
>
> [[NSNotificationCenter defaultCenter] addObserver:self
>                                          selector:@selector(fooNote:)
>                                              name:@"fooIt"
>                                            object:self] ;
>
> And then in -willTurnIntoFault, and also in -didTurnIntoFault, I remove
> such observers
>
> [self removeObservers:nil] ;
>
> * * *
>
> This normally works OK, but in some edge cases which I've not been able to
> reproduce but have analyzed by poking around with the debugger, the
> fooNote: selector does not get invoked as expected when a qualifying
> notification (name = fooIt, object = that object) is posted and I wait for
> coalescing.  If I release this object and re-fetch it from the store,
> notifications start working again.
>
> I'm thinking this could happen if maybe -willTurnIntoFault ran for some
> reason, but then object was brought back to life somehow without
> -awakeFromFetch running.
>
> Is that possible?  Am I using the correct design pattern for adding and
> removing observers?  Is it completely bullet-proof?
>
> Thanks,
>
> Jerry Krinock
>
>
> _______________________________________________
>
> 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
_______________________________________________

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: Removing object as observer in -willTurnIntoFault
      • From: Jerry Krinock <email@hidden>
References: 
 >Removing object as observer in -willTurnIntoFault (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Removing object as observer in -willTurnIntoFault
  • Next by Date: Re: SQLite Question
  • Previous by thread: Removing object as observer in -willTurnIntoFault
  • Next by thread: Re: Removing object as observer in -willTurnIntoFault
  • Index(es):
    • Date
    • Thread