• 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: Wed, 11 Sep 2013 14:13:34 +0100

On 11 Sep 2013, at 13:55, Graham Cox <email@hidden> wrote:

>
> On 11/09/2013, at 1:35 PM, Dave <email@hidden> wrote:
>
>> Is there any problem with having all notifications handled by one object that doesn't go away,
>
> Well, [NSNotificationCenter defaultCenter] is that object…

Yes, but it doesn't remember the last value of a notification, which is what I would like.

>> 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.

Yes, I am removing myself as a receiver, but ideally I want to receive these notification even if the object is dead. By this I mean, I want the last known value of the notification restored when the Object in question starts up again. At present I have to save this somewhere ugly and restore it from somewhere ugly. I just thought it would be nice to be able to just make a call something like:

-(void) reissueLastNotificationName:@"Note1" forClass:self

Rather than save it somewhere ugly 26 more times!

I  could maybe subclass NSNotificationCenter?

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


  • Follow-Ups:
    • Re: Crashing Problem calling postNotificationName
      • From: Etienne Samson <email@hidden>
    • Re: Crashing Problem calling postNotificationName
      • From: Graham Cox <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>)

  • 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