Re: Does NSNotificationCenter have zeroing weak references to observers ?
Re: Does NSNotificationCenter have zeroing weak references to observers ?
- Subject: Re: Does NSNotificationCenter have zeroing weak references to observers ?
- From: "Michael Ash" <email@hidden>
- Date: Thu, 14 Aug 2008 12:24:44 -0400
On Wed, Aug 13, 2008 at 11:22 PM, Erik Buck <email@hidden> wrote:
> In my test
> program, how can I tell the difference between an observer for which the
> NSNotificationCenter has a strong reference and an observer that is about to
> be finalized but hasn't been yet ?
Quite simple, actually. Write an object that logs in its finalizer.
Set it up as the observer for a notification. Clear all strong
references to it (zero out your local variables, etc.). Then tell the
collector to do a full collection. If it logs, then it was a weak
reference, and if it doesn't, then it was a strong reference.
To guard against stray bits of stack looking like a strong reference,
you could then drop into the debugger and use info gc-references to
see if the reference is in the notification center or somewhere else.
Mike
_______________________________________________
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