• 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: iOS: Using AppDelegate as an app-wide singleton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS: Using AppDelegate as an app-wide singleton


  • Subject: Re: iOS: Using AppDelegate as an app-wide singleton
  • From: Alex Zavatone <email@hidden>
  • Date: Wed, 02 Dec 2015 00:38:06 -0500

On Dec 2, 2015, at 12:24 AM, Luther Baker wrote:

> The conversation here is pretty loose ... and so everyone might be right in what they are intending to convey... ;-) but I thought I'd just put in a vote to stop using the term "Singleton" for this access pattern. It isn't a Singleton (unless there is historical signficance that grandfathers this incorrect term in) and I think that using the term loosely in this case actually weakens the power of a pattern vocabulary a bit.
>
> Unless you're doing something we can't see (which is possible), it is unlikely you are actually creating a Singleton. It is more likely that you are creating class methods that in some/many/most/all cases - are accessing private static instances. Similar in form to ...
>
>     [NSUserDefaults standardUserDefaults]
>     [NSNotificationCenter defaultCenter]
>
> Neither NSApplication, NSUserDefaults nor NSNotificationCenter technically adhere to the Singleton pattern -- although everyone labels this technique as such.
>
> https://en.wikipedia.org/wiki/Singleton_pattern

Yeah, but are the "effectively singletons"?
>
> 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.

Cheers.
_______________________________________________

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: iOS: Using AppDelegate as an app-wide singleton
      • From: Quincey Morris <email@hidden>
References: 
 >iOS: Using AppDelegate as an app-wide singleton (From: Carl Hoefs <email@hidden>)
 >Re: iOS: Using AppDelegate as an app-wide singleton (From: Quincey Morris <email@hidden>)
 >Re: iOS: Using AppDelegate as an app-wide singleton (From: Carl Hoefs <email@hidden>)
 >Re: iOS: Using AppDelegate as an app-wide singleton (From: Quincey Morris <email@hidden>)
 >Re: iOS: Using AppDelegate as an app-wide singleton (From: Alex Zavatone <email@hidden>)
 >Re: iOS: Using AppDelegate as an app-wide singleton (From: Luther Baker <email@hidden>)

  • Prev by Date: Re: iOS: Using AppDelegate as an app-wide singleton
  • Next by Date: Re: iOS: Using AppDelegate as an app-wide singleton
  • Previous by thread: Re: iOS: Using AppDelegate as an app-wide singleton
  • Next by thread: Re: iOS: Using AppDelegate as an app-wide singleton
  • Index(es):
    • Date
    • Thread