我有这样的代码
- (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]];
}