Skip to content

Instantly share code, notes, and snippets.

@jkhowland
Last active August 29, 2015 14:02
Show Gist options
  • Save jkhowland/89e24b5fb6e1b5048eb5 to your computer and use it in GitHub Desktop.
Save jkhowland/89e24b5fb6e1b5048eb5 to your computer and use it in GitHub Desktop.
Creating a task controller singleton for a task controller
// This goes in the header file
+ (EntryController *)sharedInstance;
// This goes in the implementation file
+ (EntryController *)sharedInstance {
static EntryController *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[EntryController alloc] init];
[sharedInstance loadFromDefaults];
});
return sharedInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment