On 2013 Sep 11, at 04:35, Dave <d...@looktowindward.com> wrote:

> the problem it was a Notification being sent to a dead object

Yup.

> Is there any problem with having all notifications handled by one object that 
> doesn't go away, and have this ship the notificationa off to the correct 
> object as long as it is still alive? The way this App is designed is I can 
> tell if the object is allocated or not and if it is allocated, then I want it 
> to receive notifications (In fact I ideally want it to get the last 
> notifications sent regardless of if the receiver was dead or alive when the 
> event occurred). At the moment I listen for the notification when the object 
> is born and stop it listening when it dies. But when it it dies I have to 
> save the data from the last notification somewhere and restore it when it is 
> reincarnated. This is common to around 26 classes and I don't want to change 
> all 26 to do the above, I'd rather the last value was remembered by the 
> source of the notification and resent somehow on request.

In real-life apps, which do complicated things on multiple threads, removing 
KVO and notification observations at the appropriate time is often tricky.  Ad 
hoc kludges are sometimes needed to supplement obvious design patterns such as 
"remove observers during -dealloc".  It looks like you're proposing a "smart" 
wrapper around the singleton NSNotificationCenter, and this is going to reduce 
the amount of code you write.  Using a delegate or making these 26 classes 
inherit from a common superclass might be another way.  Every app is different. 
 It seems like you've thought this through.  I would say to go ahead with it.


_______________________________________________

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