On 12 Sep 2013, at 20:24, Etienne Samson <samson.etie...@gmail.com> 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com