Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
return [[self alloc] init];
static dispatch_once_t pred = 0; \
__strong static id _sharedObject = nil; \
dispatch_once(&pred, ^{ \
_sharedObject = block(); \
}); \
return _sharedObject; \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.