Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Singleton with Grand Central Dispatch (GCD)
- // declare the static variable outside of the singleton method
- static MyClass *__sharedMyClass = nil;
- + (MyClass *)singleton
- {
- static dispatch_once_t once = 0;
- dispatch_once(&once, ^{__sharedMyClass = [[self alloc] init];});
- return __sharedMyClass;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement