Skip to content

Commit

Permalink
Show how to create a simple singleton with GDC
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Halgravez committed Mar 29, 2017
1 parent eb8ceeb commit c4a4cdc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Singleton/Singleton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
DFF4DDE21E8C6D1F00D9C91E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF4DDE11E8C6D1F00D9C91E /* AppDelegate.m */; };
DFF4DDEA1E8C6D1F00D9C91E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DFF4DDE91E8C6D1F00D9C91E /* Assets.xcassets */; };
DFF4DDED1E8C6D1F00D9C91E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DFF4DDEB1E8C6D1F00D9C91E /* LaunchScreen.storyboard */; };
DFF4DDF61E8C6E1000D9C91E /* AGTConnorMacLeod.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF4DDF51E8C6E1000D9C91E /* AGTConnorMacLeod.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -21,6 +22,8 @@
DFF4DDE91E8C6D1F00D9C91E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
DFF4DDEC1E8C6D1F00D9C91E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
DFF4DDEE1E8C6D1F00D9C91E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DFF4DDF41E8C6E1000D9C91E /* AGTConnorMacLeod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGTConnorMacLeod.h; sourceTree = "<group>"; };
DFF4DDF51E8C6E1000D9C91E /* AGTConnorMacLeod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGTConnorMacLeod.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -59,6 +62,8 @@
DFF4DDEB1E8C6D1F00D9C91E /* LaunchScreen.storyboard */,
DFF4DDEE1E8C6D1F00D9C91E /* Info.plist */,
DFF4DDDD1E8C6D1F00D9C91E /* Supporting Files */,
DFF4DDF41E8C6E1000D9C91E /* AGTConnorMacLeod.h */,
DFF4DDF51E8C6E1000D9C91E /* AGTConnorMacLeod.m */,
);
path = Singleton;
sourceTree = "<group>";
Expand Down Expand Up @@ -142,6 +147,7 @@
buildActionMask = 2147483647;
files = (
DFF4DDE21E8C6D1F00D9C91E /* AppDelegate.m in Sources */,
DFF4DDF61E8C6E1000D9C91E /* AGTConnorMacLeod.m in Sources */,
DFF4DDDF1E8C6D1F00D9C91E /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
15 changes: 15 additions & 0 deletions Singleton/Singleton/AGTConnorMacLeod.h
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
24 changes: 24 additions & 0 deletions Singleton/Singleton/AGTConnorMacLeod.m
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

0 comments on commit c4a4cdc

Please sign in to comment.