Whenever I see a suggestion like “subclass NSNotificationCenter”, I recoil in 
horror.

First, NSNotificationCenter is a singleton. If you subclass it, you now must 
have two notification centers. Which one is the right one to subscribe to? Do 
you only move notifications over to it that need to be cached? Or all related 
notifications as well?

This decision needs to be made on both ends of the notification. 
Congratulations, you have taken an object whose purpose is to promote loose 
coupling, and successfully turned it into a tool that tightly couples the 
sender and the listener.

The correct approach does not put the cache in the notification center, but 
rather in the sender or the userInfo dictionary.

--Kyle Sluder
(Sent from the road)

On Sep 12, 2013, at 9:40 AM, Dave <d...@looktowindward.com> wrote:

> 
> On 11 Sep 2013, at 16:33, Etienne Samson <samson.etie...@gmail.com> wrote:
> 
>> Hi !
>> 
>> I think the best way for what you're trying to do is to subclass 
>> NSNotificationCenter (or at least provide your own framework-wide singleton 
>> that quacks like it), wrap -postNotification: with some dictionary-munging 
>> code that keeps tracks of the last notification send by notification name, 
>> and have -addObserver:… (you'll have to find the one that actually is the 
>> designated call, the one all the others expect) check that cache and issue a 
>> -postNotification: call for that object only (you don't want to notify all 
>> old objects, only the one that just registered).
> 
> Great minds and all that! This is more or less what I have, see earlier post 
> for details if you are interested.
> 
> Thanks a lot
> 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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.com

_______________________________________________

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

Reply via email to