• 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: Create an NSCharacterSet constant
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create an NSCharacterSet constant


  • Subject: Re: Create an NSCharacterSet constant
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 01 Nov 2009 21:49:16 -0800
  • Thread-topic: Create an NSCharacterSet constant

On Sun, 1 Nov 2009 21:29:25 -0800, Kyle Sluder <email@hidden> said:
>I'm partial to the following construct:
>
>+ (Foo *)sharedFoo {
>  static Foo *sharedFoo;
>  dispatch_once_t once;
>  dispatch_once(&once, ^{ sharedFoo = [[foo alloc] init]; }
>  return sharedfoo;
>}

Why (I'm really asking, not arguing; I don't know anything about GCD) is
this better than the traditional:

+ (Foo*) sharedFoo {
   static Foo* sharedFoo = nil;
   if (nil == sharedFoo) sharedFoo = [[Foo alloc] init];
   return sharedFoo;
}

m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



_______________________________________________

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: Create an NSCharacterSet constant
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Create an NSCharacterSet constant
  • Next by Date: Re: Create an NSCharacterSet constant
  • Previous by thread: Re: Create an NSCharacterSet constant
  • Next by thread: Re: Create an NSCharacterSet constant
  • Index(es):
    • Date
    • Thread