Skip to content

Instantly share code, notes, and snippets.

@qnoid
Created March 9, 2014 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnoid/9446306 to your computer and use it in GitHub Desktop.
Save qnoid/9446306 to your computer and use it in GitHub Desktop.
@interface Foo()
@property(nonatomic, strong) dispatch_group_t lock;
@end
@implementation Foo
-(id)init
{
self = [super init];
if(!self){
return nil;
}
_lock = dispatch_group_create();
dispatch_group_enter(_lock);
//do work
dispatch_group_leave(_lock);
return self;
}
-(void)someMethod
{
dispatch_group_wait(self.lock, DISPATCH_TIME_FOREVER);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment