Skip to content

Instantly share code, notes, and snippets.

@plantpurecode
Created September 20, 2012 22:54
Show Gist options
  • Save plantpurecode/3758830 to your computer and use it in GitHub Desktop.
Save plantpurecode/3758830 to your computer and use it in GitHub Desktop.
Locking with blocks
@interface NSLock (JRAdditions)
- (void)lockWithBlock:(dispatch_block_t)block;
@end
@implementation NSLock (JRAdditions)
- (void)lockWithBlock:(dispatch_block_t)block {
NSParameterAssert(block);
[self lock];
block();
[self unlock];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment