On 11/09/2013, at 1:35 PM, Dave <[email protected]> wrote:
> Is there any problem with having all notifications handled by one object that
> doesn't go away,
Well, [NSNotificationCenter defaultCenter] is that object...
> 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
The correct way to deal with this is to remove yourself as a receiver of
notifications when you are deallocated. The documentation, in its roundabout
way, does state this.
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
...
[super dealloc];
}
This pattern works without resorting to any odd hacks to avoid notifying a dead
object. Since that removes all possible notifications for 'self' it's a good
habit to add this automatically as soon as you add any notificaition
observations to your code.
--Graham
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]