Skip to content

Instantly share code, notes, and snippets.

@tonyalbor
Created January 15, 2014 01:48
Show Gist options
  • Save tonyalbor/8429351 to your computer and use it in GitHub Desktop.
Save tonyalbor/8429351 to your computer and use it in GitHub Desktop.
implement singleton class
static DataSource *_sharedDataSource = nil;
+ (DataSource *)sharedDataSource {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedDataSource = [[DataSource alloc] init];
// further initialization
});
return _sharedDataSource;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment