Skip to content

Instantly share code, notes, and snippets.

@EvgenyKarkan
Last active January 2, 2016 16:39
Show Gist options
  • Save EvgenyKarkan/8331475 to your computer and use it in GitHub Desktop.
Save EvgenyKarkan/8331475 to your computer and use it in GitHub Desktop.
Singleton.
#pragma mark Singleton stuff
static id _sharedInstance;
+ (EKCoreDataProvider *)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[EKCoreDataProvider alloc] init];
});
return _sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = nil;
_sharedInstance = [super allocWithZone:zone];
});
return _sharedInstance;
}
- (id)copyWithZone:(NSZone *)zone
{
return self;
}
+ (id)new
{
NSException *exception = [[NSException alloc] initWithName:kEKException
reason:kEKExceptionReason
userInfo:nil];
[exception raise];
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment