• 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: Dave Camp <email@hidden>
  • Date: Mon, 3 Aug 2009 19:14:54 -0700

On Aug 3, 2009, at 6:32 PM, Kiel Gillard wrote:
On 04/08/2009, at 10:59 AM, Kyle Sluder wrote:
On Mon, Aug 3, 2009 at 5:47 PM, Kiel Gillard<email@hidden> wrote:
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 ;-)

The Objective-C 2.0 Programming Guide prescribes the use of direct ivar access inside an initializer[1] and inside dealloc[2].

[1] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#/ /apple_ref/doc/uid/TP30001163-CH22-SW14
[2] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#/ /apple_ref/doc/uid/TP30001163-CH17-SW16

Thanks for these - much appreciated. The -dealloc commentary was very helpful. For the OP, this means care should be taken to unobserve key paths before dealloc. One way this could be done by observing NSApplicationWillTerminateNotification.

Assuming the objects you were observing lasted as long as the app, yes. For anything shorter term (e.g. document data), you still need to know when the object will be dealloced and stop observing before then.


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


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

  • Prev by Date: Re: text control for keyboard shortcut input?
  • Next by Date: Re: NSString and regular expressions
  • Previous by thread: Re: Avoiding KVO in dealloc?
  • Next by thread: Re: NSString and regular expressions
  • Index(es):
    • Date
    • Thread