• 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: [ANN] Cocoa Style for ObjC: 1 and 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] Cocoa Style for ObjC: 1 and 2


  • Subject: Re: [ANN] Cocoa Style for ObjC: 1 and 2
  • From: Ken Ferry <email@hidden>
  • Date: Wed, 27 Oct 2004 17:13:54 -0400

On Wed, 27 Oct 2004 00:06:31 -0700, Scott Stevenson
<email@hidden> wrote:
>
> On Oct 26, 2004, at 11:47 PM, M. Uli Kusterer wrote:
>
> > One note: Your choice of selector names for singletons isn't
> > necessarily the only one. IIRC the only place in Cocoa where "shared"
> > is used is NSWorkspace, and probably not because it's a singleton, but
> > rather because the object seems to be shared between applications
>
> It's not the only one. Here are a few:
>
> NSFontManager +sharedFontManager
> NSFontManager +sharedFontPanel
> NSColorPanel +sharedColorPanel
> NSPrintInfo +sharedPrintInfo
> NSHTTPCookieStorage +sharedCookieStorage
> NSHelpManager +sharedHelpManager

I know we're discussing what the convention is, not what it should be,
but this has always bothered me. Well, bothered me a little bit, it
isn't a huge deal. ;-)

Does not saying

[NSFontManager sharedFontManager]

feel like you're repeating yourself? How many times do you need to
specify that you're after a font manager?

In my own code I always use +[Class sharedInstance]. Makes it easier
to remember the method name too. For example, Apple's way you need to
remember that the method is

+[NSHTTPCookieStorage sharedCookieStorage]

and not

+[NSHTTPCookieStorage sharedHTTPCookieStorage]

-Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [ANN] Cocoa Style for ObjC: 1 and 2
      • From: Scott Stevenson <email@hidden>
References: 
 >[ANN] Cocoa Style for ObjC: 1 and 2 (From: Scott Stevenson <email@hidden>)
 >Re: [ANN] Cocoa Style for ObjC: 1 and 2 (From: Scott Stevenson <email@hidden>)

  • Prev by Date: Re: [ANN] Cocoa Style for ObjC: 1 and 2
  • Next by Date: Re: [ANN] Cocoa Style for ObjC: 1 and 2
  • Previous by thread: Re: [ANN] Cocoa Style for ObjC: 1 and 2
  • Next by thread: Re: [ANN] Cocoa Style for ObjC: 1 and 2
  • Index(es):
    • Date
    • Thread