Last active
December 26, 2015 20:29
-
-
Save fjolnir/7209226 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 NSThread (Blocks) | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
- (void)cy_executeBlock:(dispatch_block_t const)aBlock afterDelay:(NSTimeInterval const)aDelay | |
{ | |
dispatch_block_t const blockCopy = [[aBlock copy] performSelector:NSSelectorFromString(@"retain")]; | |
AfterDelay(aDelay, ^{ | |
[self performSelector:@selector(_cy_executeBlock:) | |
onThread:self | |
withObject:blockCopy | |
waitUntilDone:NO]; | |
}); | |
} | |
- (void)_cy_executeBlock:(dispatch_block_t const)aBlock | |
{ | |
NSParameterAssert(aBlock); | |
aBlock(); | |
[aBlock performSelector:NSSelectorFromString(@"release")]; | |
} | |
#pragma clang diagnostic pop | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment