Skip to content

Instantly share code, notes, and snippets.

@leilee
Created July 25, 2017 06:49
Show Gist options
  • Save leilee/636ecf289b6c421ec764d9c02031d667 to your computer and use it in GitHub Desktop.
Save leilee/636ecf289b6c421ec764d9c02031d667 to your computer and use it in GitHub Desktop.
+ (id)sharedInstance
{
static __weak ASingletonClass *instance;
ASingletonClass *strongInstance = instance;
@synchronized(self) {
if (strongInstance == nil) {
strongInstance = [[[self class] alloc] init];
instance = strongInstance;
}
}
return strongInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment