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 <je...@ieee.org> 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 (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: > https://lists.apple.com/mailman/options/cocoa-dev/dado.colussi%40gmail.com > > This email sent to dado.colu...@gmail.com _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com