Created
September 20, 2012 22:54
-
-
Save plantpurecode/3758830 to your computer and use it in GitHub Desktop.
Locking with blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSLock (JRAdditions) | |
- (void)lockWithBlock:(dispatch_block_t)block; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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