私はこのようなコードを持っています
- (IBAction)onClick:(id)sender {
NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:) object:ph];
[thread start];
}
スレッドがセレクターを実行した後に何かを行うにはどうすればよいですか (ログを表示するか、smth を実行します)。
私はこのようなコードを持っています
- (IBAction)onClick:(id)sender {
NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:) object:ph];
[thread start];
}
スレッドがセレクターを実行した後に何かを行うにはどうすればよいですか (ログを表示するか、smth を実行します)。
残念ながら、GCD (サポートできない可能性がある iOS 4.x の機能) を使用せずにこの質問に簡単に答えることはできないためNSNotificationCenter
、メソッドが完了したら、通知を使用してラッチします。
- (IBAction)onClick:(id)sender {
NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:) object:ph];
[thread start];
}
-(void)adapter:(NSObject*)arg {
//... process and such
[[NSNotificationCenter defaultCenter]postNotification:[NSNotification notificationWithName:@"Thread_Done" object:nil]];
}