Re: Create an NSCharacterSet constant
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