Skip to content

Instantly share code, notes, and snippets.

@dmur
Last active August 20, 2018 13:45
Show Gist options
  • Select an option

  • Save dmur/5689050 to your computer and use it in GitHub Desktop.

Select an option

Save dmur/5689050 to your computer and use it in GitHub Desktop.

Revisions

  1. dmur revised this gist Jan 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SampleSingleton.m
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    + (id)sharedInstance
    {
    static YourClass *sharedInstance = nil;
    static <#ClassName#> *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    sharedInstance = [[self alloc] init];
  2. dmur renamed this gist Jun 3, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. dmur revised this gist Jun 1, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion singleton.m
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    + (id)sharedInstance {
    + (id)sharedInstance
    {
    static YourClass *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
  4. dmur created this gist Jun 1, 2013.
    8 changes: 8 additions & 0 deletions singleton.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    + (id)sharedInstance {
    static YourClass *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
    }