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+Extensions.h" | |
… | |
- (void)doSomething { | |
[self performBlockInBackground:^{ | |
NSLog(@"バックグラウンド処理でごにょごにょ"); | |
}]; | |
} |
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
@interface NSObject (Extensions) | |
typedef void (^VoidBlock)(void); | |
- (void)performBlock:(VoidBlock)block; | |
- (void)performBlock:(VoidBlock)block afterDelay:(NSTimeInterval)delay; | |
- (void)performBlockOnMainThread:(VoidBlock)block; | |
- (void)performBlockOnMainThread:(VoidBlock)block afterDelay:(NSTimeInterval)delay; | |
- (void)performBlockInBackground:(VoidBlock)block; |
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+Extensions.h" | |
@implementation NSObject (Extensions) | |
- (void)performBlock:(VoidBlock)block { | |
[self performSelector:@selector(executeBlock:) withObject:[block copy]]; | |
} | |
- (void)performBlock:(VoidBlock)block afterDelay:(NSTimeInterval)delay { | |
[self performSelector:@selector(executeBlock:) withObject:[block copy] afterDelay:delay]; |
OlderNewer