我有许多线程通过 performSeleactoreOnMainThread 方法调用以下函数:
-(void) showAlert: (NSString *)message{
if ([NSRunLoop currentRunLoop] != [NSRunLoop mainRunLoop]) {
NSLog(@"<< perform in main thread>>");
[self performSelectorOnMainThread:@selector(showAlert:) withObject:message waitUntilDone:NO];
}
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Info" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
因为,无论如何,这个方法只会在主线程上调用,我没有得到 EXC_BAD_ACCESS 崩溃的原因:[alert show]
而这种崩溃只是偶尔发生。请帮忙。