这是我的代码:
#ifdef DEBUG UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"JSON Parsing Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; [alertView release]; #endif
该代码在后台线程中执行(负责解析),错误只发生在其他时间.任何想法在这里有什么问题?
解决方法
不要从后台线程弄乱UI.在主线程上创建一个方法并调用该方法:
[someObject performSelectorOnMainThread:@selector(showDebug:) withObject:@"JSON Parsing Error" waitUntilDone:YES];