从后台线程显示的 UIAlertView 并且没有委托创建 EXC_BAD_ACCESS
这是我的代码:
#ifdef DEBUG
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"JSON Parsing Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
#endif
该代码在后台线程中执行(负责解析),并且错误仅每隔一段时间发生一次。知道这里有什么问题吗?
Here is my code:
#ifdef DEBUG
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"JSON Parsing Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
#endif
This code is executed in a background thread (responsible for parsing), and the error only happens every other time. Any idea on what is the problem here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要从后台线程弄乱 UI。创建一个方法并在主线程上调用该方法:
Dont mess with the UI from the background thread. Create a method and call that method on the main thread:
您不应该在单独的线程中执行 UI 代码。
线程和您的用户界面
You shouldn't execute UI code in separate thread.
Threads and Your User Interface