• 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: Crashing Problem calling postNotificationName
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing Problem calling postNotificationName


  • Subject: Re: Crashing Problem calling postNotificationName
  • From: Dave <email@hidden>
  • Date: Thu, 12 Sep 2013 20:44:05 +0100

On 12 Sep 2013, at 20:24, Etienne Samson <email@hidden> wrote:
>
> That's not true : you won't get notifications sent by the Cocoa framework, because it will use `[NSNotificationCenter defaultCenter]` and you have (obviously) no way to change the sender.
>
> I feel like I'm playing the devil's advocate here Dave, but you'd have a more fool-proof solution with the cache solution I described. You won't have the problem pointed out by Kyle that you end up with 2 notification centers (and can't cache Cocoa's own notifications unless you have the subclass register with the default center). Maybe you'll have 26-or-more registerObserver: calls to change (to add the "then check cached notification" call), but in the end run, you've just removed a dependency on a subclass whose superclass you know nothing about. Again (and I speak from experience), better be safe than sorry if NSNotificationCenter semantics change and your app stop working.


The way this was setup before I added any of this was that the whole app calls a method called getNotificationCenter that returns [NSNotificationCenter defaultCenter], that's the only notification center the App knows about.

All I have done it make a subclass of NSNotificationCenter, called LTWCachedNotificationCenter and I return that instead of  [NSNotificationCenter defaultCenter] in the getNotificationCenter method. The rest of the app stays the same, apart from the places that call the new methods.

All the Best
Dave


_______________________________________________

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: 
 >Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Graham Cox <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Etienne Samson <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Kyle Sluder <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Kyle Sluder <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Dave <email@hidden>)
 >Re: Crashing Problem calling postNotificationName (From: Etienne Samson <email@hidden>)

  • Prev by Date: Re: Crashing Problem calling postNotificationName
  • Next by Date: Re: Crashing Problem calling postNotificationName
  • Previous by thread: Re: Crashing Problem calling postNotificationName
  • Next by thread: Re: Crashing Problem calling postNotificationName
  • Index(es):
    • Date
    • Thread