最終更新:2009-04-14 (火) 09:02:01 (5490d)
NSThread
Top / NSThread
例
//MyInstanceThreadMethodの中でもインスタンス変数を書き換えるところは@synchronizedでかこっておく //threadを起動 [NSThread detachNewThreadSelector:@selector(MyInstanceThreadMethod:) toTarget:self withObject:self]; //threadの処理を記述 - (void)MyInstanceThreadMethod:(id)param { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int i; for(i=0; i<60*60*24; i++){ [NSThread sleepForTimeInterval:1.0]; @synchronized(self){ selectedIndex = i%5; } NSLog(@"%d", i%5); } [pool release]; }