-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show how to create a simple singleton with GDC
- Loading branch information
Roberto Halgravez
committed
Mar 29, 2017
1 parent
eb8ceeb
commit c4a4cdc
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AGTConnorMacLeod.h | ||
// Singleton | ||
// | ||
// Created by Roberto Manuel Halgravez Perea on 3/29/17. | ||
// Copyright © 2017 RHalgravez. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface AGTConnorMacLeod : NSObject | ||
|
||
+(instancetype) sharedConnorMacLeod; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// AGTConnorMacLeod.m | ||
// Singleton | ||
// | ||
// Created by Roberto Manuel Halgravez Perea on 3/29/17. | ||
// Copyright © 2017 RHalgravez. All rights reserved. | ||
// | ||
|
||
#import "AGTConnorMacLeod.h" | ||
|
||
@implementation AGTConnorMacLeod | ||
|
||
+(instancetype) sharedConnorMacLeod { | ||
|
||
static dispatch_once_t onceToken; | ||
static AGTConnorMacLeod *shared; | ||
dispatch_once(&onceToken, ^{ | ||
shared = [[AGTConnorMacLeod alloc] init]; | ||
}); | ||
|
||
return shared; | ||
} | ||
|
||
@end |