I’ve seen bog-standard code to initialize a shared instance like:
> + (SomeSingleton *) sharedInstance
> {
> static SomeSingleton *sharedInstance = nil;
> static dispatch_once_t onceToken;
> static dispatch_once_t onceToken;
> dispatch_once(&onceToken, ^{
> sharedInstance = [[SomeSingleton alloc] init];
> });
> return sharedInstance;
> }
What happens if that initialization fails? Shouldn’t there be a test for NIL
and a reset of the “onceToken” somewhere?… (Or is the chance of failure too
unlikely?)
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]