NSOperationQue は(当然のことながら)別スレッドで動くので 中の NSOperation からUIKit を扱うときは performSelectorOnMainThread を使用してやりたい処理をメインスレッドにスケジュールしてやる。

   1  @interface	Operation : NSOperation {
   2  }
   3  @end
   4  @implementation	Operation
   5  -	(void)
   6  Sub {
   7  NSLog( @"Sub:%@", [ NSThread currentThread ] );
   8      //  UIKit を使う処理
   9  }
  10  
  11  -	(void)
  12  main {
  13  NSLog( @"main:%@", [ NSThread currentThread ] );
  14  	[ self performSelectorOnMainThread:@selector(Sub) withObject:nil waitUntilDone:NO ];
  15  }
  16  @end
  17  
  18  
  19  {
  20  	NSOperationQueue*	w = [ [ [ NSOperationQueue alloc ] init ] autorelease ];
  21  	[ w addOperation:[ [ Operation alloc ] init ] ];
  22  }

posted by Face Saturn on Tue 16 Nov 2010 at 02:29
Contents
NSOperation が動くスレッド
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ