• 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: Detecting Managed Object Property Change From Undo Redo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting Managed Object Property Change From Undo Redo


  • Subject: Re: Detecting Managed Object Property Change From Undo Redo
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 25 Jan 2015 23:19:55 -0800

> On 2015 Jan 25, at 22:03, Kyle Sluder <email@hidden> wrote:
>
> On Sun, Jan 25, 2015, at 05:16 PM, Jerry Krinock wrote:

>> • When an observer is being torn down you can remove all observers with
>> one line of code,
>>     [NSNotificationCenter removeObserver:self].

> This is a dangerous API. If your superclass has registered for any
> observations, you will unregister before your superclass hears about it.

I see what you mean, that if the superclass needed for some reason to receive some notification at the bitter end of an object’s life, that line of code would break it.  I’m trying to imagine such a requirement.  Maybe to push changes to a data model in a view that was editing?  But we have various -endEditing methods for that.

On the other hand, I’ve seen many crashes occur from not removing observers early enough.  In general, as soon as it’s confirmed that an object is going away, the very first thing I do is to remove all of its observances.  It has worked for me, but from now on I’ll think about what you said.

> You can use the magic of C's sizeof keyword to avoid repeating yourself
> for each observed keypath:

And C arrays.  Very cool, Kyle.


_______________________________________________

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


References: 
 >Detecting Managed Object Property Change From Undo Redo (From: Richard Charles <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Mike Abdullah <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Jerry Krinock <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Detecting Managed Object Property Change From Undo Redo
  • Next by Date: Re: Any way to force a window under the menu bar?
  • Previous by thread: Re: Detecting Managed Object Property Change From Undo Redo
  • Next by thread: Re: Detecting Managed Object Property Change From Undo Redo
  • Index(es):
    • Date
    • Thread