Created
February 10, 2014 06:45
-
-
Save imoldman/8911441 to your computer and use it in GitHub Desktop.
handy category for run some block on a NSThread
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
#import <Foundation/Foundation.h> | |
@interface NSThread (RunBlock) | |
- (void)performBlock:(void(^)())block; | |
- (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay; | |
@end |
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
#import "NSThread+RunBlock.h" | |
@implementation NSThread (RunBlock) | |
- (void)performBlock:(void(^)())block | |
{ | |
[self performSelector:@selector(onlyForRunBlock:) onThread:self withObject:block waitUntilDone:NO]; | |
} | |
- (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay | |
{ | |
[self performBlock:^{ | |
[self performSelector:@selector(onlyForRunBlock:) withObject:block afterDelay:delay]; | |
}]; | |
} | |
- (void)onlyForRunBlock:(void(^)())block | |
{ | |
block(); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment