Skip to content

Instantly share code, notes, and snippets.

@kluivers
Created February 27, 2012 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kluivers/1925063 to your computer and use it in GitHub Desktop.
Save kluivers/1925063 to your computer and use it in GitHub Desktop.
A singleton implementation in Objective-C
+ (id) sharedInstance {
static dispatch_once_t predicate = 0;
__strong static id shared = nil;
dispatch_once(&predicate, ^{
shared = [[self alloc] init];
});
return shared;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment