• 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: Avoiding KVO in dealloc?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding KVO in dealloc?


  • Subject: Re: Avoiding KVO in dealloc?
  • From: Kiel Gillard <email@hidden>
  • Date: Tue, 4 Aug 2009 10:47:23 +1000

On 04/08/2009, at 10:26 AM, Kyle Sluder wrote:

On Aug 3, 2009, at 5:03 PM, Kiel Gillard <email@hidden> wrote:
Unless, of course, you have code in your setter method that handles changes to and from nil. For example, you may add or remove self as an observer for keypaths of an different object value. This would save repeating the change handling code in your init, setter and dealloc methods.

No, this is precisely what you should not do. -init and -dealloc should not invoke accessor methods, because the object is in a partially constructed state that subclasses (including the dynamically created ones KVO makes) often can't handle.

Do you have a documentation reference for that? I would have expected the isa swizzling to be an implementation detail of the runtime that is handled before my subclass inits. Of course, what I expect and what happens in reality do not always match ;-)


Kiel

_______________________________________________

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: Avoiding KVO in dealloc?
      • From: Kyle Sluder <email@hidden>
References: 
 >Avoiding KVO in dealloc? (From: Todd Heberlein <email@hidden>)
 >Re: Avoiding KVO in dealloc? (From: Kyle Sluder <email@hidden>)
 >Re: Avoiding KVO in dealloc? (From: Kiel Gillard <email@hidden>)
 >Re: Avoiding KVO in dealloc? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Avoiding KVO in dealloc?
  • Next by Date: Re: [IB] - can't assign keyboard shortcut to a menu item
  • Previous by thread: Re: Avoiding KVO in dealloc?
  • Next by thread: Re: Avoiding KVO in dealloc?
  • Index(es):
    • Date
    • Thread