Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:45
Show Gist options
  • Save priore/7163531 to your computer and use it in GitHub Desktop.
Save priore/7163531 to your computer and use it in GitHub Desktop.
How to use GDC for create a singleton class
+ (id)sharedInstance
{
static dispatch_once_t once;
static id instance;
dispatch_once(&once, ^{
instance = self.new;
});
return instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment