Created
April 24, 2011 16:57
-
-
Save stuartcarnie/939693 to your computer and use it in GitHub Desktop.
Blocks category for NSObject
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
// credits to Matthias Plappert | |
#import <Foundation/Foundation.h> | |
@interface NSObject (PWBlocks) | |
- (void)performBlock:(void (^)(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 "NSObject+Blocks.h" | |
@implementation NSObject (PWBlocks) | |
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay | |
{ | |
int64_t delta = (int64_t)(NSEC_PER_SEC * delay); | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delta), dispatch_get_main_queue(), block); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment