Skip to content

Instantly share code, notes, and snippets.

View taka328w's full-sized avatar

Takahiro Ooishi taka328w

  • mitsubachiworks inc.
View GitHub Profile
@taka328w
taka328w / gist:2519425
Created April 28, 2012 14:24
バックグランド処理(Blocks)
#import "NSObject+Extensions.h"
- (void)doSomething {
[self performBlockInBackground:^{
NSLog(@"バックグラウンド処理でごにょごにょ");
}];
}
@taka328w
taka328w / NSObject+Extensions.h
Created April 28, 2012 14:42
NSObject+Extensions.h
@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;
@taka328w
taka328w / NSObject+Extensions.m
Created April 28, 2012 14:52
NSObject+Extensions.m
#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];