• 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: NSNotificationCenter not always working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotificationCenter not always working?


  • Subject: Re: NSNotificationCenter not always working?
  • From: Matt Neuburg <email@hidden>
  • Date: Fri, 19 Nov 2010 12:16:13 -0800

> Date: Fri, 19 Nov 2010 11:58:35 -0800
> From: Laurent Daudelin <email@hidden>
> Subject: NSNotificationCenter not always working?
>
> Is there a way to debug why the same "postNotificationName:object:userInfo:" would not work the second time it's called?

In a word - no. This is one of the worst aspects of NSNotificationCenter; I have complained about it many times, filed bugs, etc., and I suggest you do the same. In particular we need a way to ask the center what's registered with it, and for what.

The last time I had a problem such as you describe, it turned out that my own code, far off in a different file, was unregistering me - so, the second time the notification was posted, I was no longer an observer. This was discovered essentially by simple reading all my code really carefully. In fact, by the time I figured it out, I had actually stopped using notifications in that project, because they were so hard to debug.

I complained about this and did receive an interesting suggestion about breakpoints; but this is not as good as a simple ability to query the notification center would be.

<http://www.cocoabuilder.com/archive/cocoa/157926-how-to-debug-notification-that-never-received.html>

And of course a tiny misspelling in the name of a notification will get you too. This can be largely avoided by using a #define but people are often lazy about that.

m._______________________________________________

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

  • Follow-Ups:
    • Re: NSNotificationCenter not always working?
      • From: Laurent Daudelin <email@hidden>
  • Prev by Date: NSNotificationCenter not always working?
  • Next by Date: Re: NSNotificationCenter not always working?
  • Previous by thread: NSNotificationCenter not always working?
  • Next by thread: Re: NSNotificationCenter not always working?
  • Index(es):
    • Date
    • Thread