Re: KVO and object release timing (for a NSCollectionView)
Re: KVO and object release timing (for a NSCollectionView)
- Subject: Re: KVO and object release timing (for a NSCollectionView)
- From: Kyle Sluder <email@hidden>
- Date: Sat, 23 Jan 2010 12:16:12 -0800
On Sat, Jan 23, 2010 at 1:48 AM, vincent habchi <email@hidden> wrote:
> The problem is that when the represented object is removed from the array controller, the corresponding NSView is not immediately released. Instead, there is an implied CAAnimation (or something similar) that makes the NSView slowly fade away. Net result is that the NSView survives some tenths of a second after the represented object is released, and the KVO unregistering crashes.
Hooray for retain cycles; if you avoid them you get overrelease bugs!
(I can't wait for garbage collection.)
This happens a lot in any non-trivial context. You might want to have
some sort of notification or delegate method that keeps your object
alive long enough. Putting code after calling [super dealloc] is
usually a bad idea, because self will be a garbage pointer, and how
many of us are so careful about pointer lifetimes that we're immune to
writing use-after-free bugs, especially when we return to the code six
months later?
--Kyle Sluder
_______________________________________________
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