Skip to content

Instantly share code, notes, and snippets.

@luckyduck

luckyduck/iOS Singleton

Last active Dec 19, 2015
Embed
What would you like to do?
//Singleton.h
+ (id) sharedInstance;
// singleton.m
+ (id)sharedInstance {
static BackendResource *shared = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shared = [[self alloc] init];
});
return shared;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.