Re: Deallocation while key value observers still registered
Re: Deallocation while key value observers still registered
- Subject: Re: Deallocation while key value observers still registered
- From: aglee <email@hidden>
- Date: Tue, 25 May 2010 09:08:33 -0700 (PDT)
- Date-warning: Date header was inserted by spool002.mac.com
On May 25, 2010, at 10:54 AM, Kyle Sluder <email@hidden> wrote:
This sounds off& you're deregistering obeservers in your observee's
-dealloc?
In general this would sound off to me too, on the principle that observees normally don't know who their observers are. It only makes sense to me if the observee added the observers to itself in the first place, on the principle that whoever adds an observer should take it away.
On May 25, 2010, at 09:49 AM, Roland King <email@hidden> wrote:
That's not it then, in Snow Leopard there was a change so that message was only emitted at the end of the dealloc() method instead of at the start which allowed you to deregister your observers in dealloc() and not get this error. In Leopard and in (I think still in) iPhone OS you get the message at the start of dealloc whether you are just about to deregister your observers or not.
Thanks for this -- I vaguely remember something about the change in Snow Leopard but it hadn't clearly registered in my mind.
I had an idea for a perverse hack to deal with the problem in Leopard, which was to to override release and do the deregistering there if the retainCount is 1, thus sneaking in the deregistering just before dealloc but no sooner.
--Andy
On 25-May-2010, at 9:33 PM, Gideon King wrote:
10.6.3
On 25/05/2010, at 11:17 PM, Roland King wrote:
what version of what operating system are you using?
On 25-May-2010, at 9:14 PM, Gideon King wrote:
Hi, I'm getting the message:
An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <all my observers>
But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers.
Any clues where to look?
Thanks
Gideon
_______________________________________________
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
_______________________________________________
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