• 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: how to debug notification that's never received?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to debug notification that's never received?


  • Subject: Re: how to debug notification that's never received?
  • From: Camillo Lugaresi <email@hidden>
  • Date: Sun, 5 Mar 2006 03:20:02 +0100

On 05/mar/06, at 02:49, Matt Neuburg wrote:

On Fri, 03 Mar 2006 13:17:32 -0800, Matt Neuburg <email@hidden> said:
In class A, I post a notification. I know from logging that the posting code
is being executed.


In class B, I've registered to receive that notification, but it never
arrives.


I've double-checked the registration, dicking with the notification name and
all sorts of things, but I can't make the notification arrive.


In the end, after about two hours of dicking around, I simply threw up my
hands and solved the problem a different way. I never figured out what the
problem was! So how might I have debugged this? Is there a way to dig into
the internals of the notification center and see who is registered to
receive what, and to find out exactly what happens when the notification is
posted? m.

I think we may take it as stipulated that I know how to register for and
post a notification and that I've done it zillions of times. The question
was not what might be wrong with my registration or posting code (nothing
was). I did eventually find the problem, but not by using the debugger; I
simply had to read a lot of code, by eye. After some hours, I found some
code that was sneaking in and unregistering me, which is why I didn't
receive the notification when it was posted.


The question was how I might avoid this line-by-line reading, and use the
debugger or some other technique to find the problem. It would have been
nice to be able to probe the notification center itself, e.g. somehow
watching objects get registered and unregistered. It appears, however, that
there is no way to do this. This surprises me greatly; after all, you can
probe KVO with -observationInfo, so why isn't there something similar for
NSNotificationCenter? I've filed a feature request for this. m.

Use gdb. Set breakpoints on the NSNotificationCenter methods for adding/removing observers, and give the breakpoints an action that prints the necessary information and continues. If you need something fancier, subclass NSNotificationCenter and use poseAsClass:.


Camillo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: how to debug notification that's never received? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Nib XML format question
  • Next by Date: Core Data & prepareSavePanel
  • Previous by thread: Re: how to debug notification that's never received?
  • Next by thread: Radio Button Matrix Bindings
  • Index(es):
    • Date
    • Thread