• 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: Does NSNotificationCenter have zeroing weak references to observers ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Does NSNotificationCenter have zeroing weak references to observers ? (From: Erik Buck <email@hidden>)

  • Prev by Date: Re: Is this a bug, or am I hacking?
  • Next by Date: cocoa window in carbon?
  • Previous by thread: Re: Does NSNotificationCenter have zeroing weak references to observers ?
  • Next by thread: CoreData, Object/Array Controllers and KVO
  • Index(es):
    • Date
    • Thread