2010年6月5日土曜日

NSOperationによるマルチスレッド

NSThreadの感覚で利用できるNSOperationの方法:

プロパティ:
NSOperationQueue *queue;

メソッド:
- (void)awakeFromNib
{
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(subThreadMethod:) object:nil];
queue = [[NSOperationQueue alloc] init];
[queue addOperation:operation];
}

- (void)subThreadMethod:(id)object
{
NSLog(@"SUB THREAD");
}

0 件のコメント: