0

私のアプリでは、ユーザーがスタートボタンを押した後、forサイクルでコードを実行します。この間、アプリケーションがユーザーの操作に責任を持つようにするにはどうすればよいですか?C#にはBackgroundWorkerクラスがありますが、IOSに似たものはありますか?

4

2 に答える 2

2

次のようにgcdを使用します

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^  {  
   //Put your heavy code here it will not block the user interface
});
于 2012-06-17T19:49:09.507 に答える
1

次のようなセレクターを使用できます。

[self performSelectorInBackground:@selector(yourForCycle:) withObject:nil];


-(void)yourForCycle:(id)sender {

    //Your for cycle...
}
于 2012-06-17T19:56:35.883 に答える