• 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: Singleton Help ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Singleton Help ...


  • Subject: Re: Singleton Help ...
  • From: Mic Pringle <email@hidden>
  • Date: Fri, 13 Mar 2009 10:54:45 +0000

But I thought that it was best practice to remove yourself from the
notification center before terminating your application, as doesn't
the notification center live in the objective-c runtime and therefore
is always active, regardless of whether your application is or isn't ?

-Mic

2009/3/13 Mike Abdullah <email@hidden>:
> By definition, if it's a singleton, it will exist for the lifetime of the
> program; there is no risk of the notification centre sending messages to a
> now non-existent object.
>
> On 13 Mar 2009, at 10:31, Mic Pringle wrote:
>
>> Hi,
>>
>> I've been looking into creating a singleton class to manage some
>> objects that I have that I'd like to be globally available. I've been
>> reading through
>> http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks
>> well except I now have the following question ...
>>
>> I'd like my singleton to observe the NSWorkspace notifications
>> applicationDidLaunch and applicationDidTerminate. I can setup the
>> observations in the init method, but how to I go about removing them ?
>> You would normally do in the dealloc method, but it seems you're not
>> meant to override dealloc in a singleton ? Would it suffice to put
>> them in the overridden release method ? If so, does this get called
>> automatically when I close the application ?
>>
>> If I can't remove the notifications, I could end up with the
>> notification centre try to foward them to an object that no longer
>> exists.
>>
>> Thanks
>>
>> -Mic
>> _______________________________________________
>>
>> 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
>
>
_______________________________________________

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: Singleton Help ...
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: Singleton Help ...
      • From: Sandy McGuffog <email@hidden>
References: 
 >Singleton Help ... (From: Mic Pringle <email@hidden>)
 >Re: Singleton Help ... (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Singleton Help ...
  • Next by Date: Re: Singleton Help ...
  • Previous by thread: Re: Singleton Help ...
  • Next by thread: Re: Singleton Help ...
  • Index(es):
    • Date
    • Thread