Re: iOS: Using AppDelegate as an app-wide singleton
Re: iOS: Using AppDelegate as an app-wide singleton
- Subject: Re: iOS: Using AppDelegate as an app-wide singleton
- From: Quincey Morris <email@hidden>
- Date: Tue, 01 Dec 2015 22:21:04 -0800
- Feedback-id: 167118m:167118agrif8a:167118soRIVe_FhK:SMTPCORP
On Dec 1, 2015, at 21:38 , Alex Zavatone <email@hidden> wrote:
>
> On Dec 2, 2015, at 12:24 AM, Luther Baker wrote:
>
>> Alex, the API uses lots of different words to grab a-hold of the so-called "standard", "default" or "shared" static instance. Unfortunately, I'm not aware of any docs that specify when to use which adjective or if any one particular adjective should be used when creating a real Singleton ... since none of these are!
>
> I just remember looking into Apple's implemented conventions on this last week in iOS and didn't have time to fully look this up. It's just what I noticed they were doing in a few areas that escape me at the moment.
>
> Except for the application delegate, which does use sharedApplication as its accessor.
On the naming question, my earlier objection was not about “shared”, but about the name not saying a shared *what*.
Regarding standard vs default vs shared, I suspect there’s no real Apple policy involved, but I believe that generally they mean what they say. ‘standardUserDefaults’ is the standard (i.e. ordinary, regular) user defaults object, but an app can certainly create non-standard ones. ‘defaultNotificationCenter’ is the notification center that apps use — mostly — in default of anything more particular, such as a distributed notification center, so again there can be others. ‘shared…’ is the term that means there’s only one the application should use. In that case, there’s no real presumption that another object of the class can’t be created, just that you’re not supposed to try.
_______________________________________________
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