我正在使用网络服务创建聊天应用程序。在这里,我将调用 Web 服务,在收到消息后,我必须在表格 View 中显示它们,而且我发送的任何内容也必须显示在表格 View 中。为此,我将 UIText
字段放在(上侧)表格 View 上方,无论我键入什么并按下发送按钮消息都会显示在表格中,并且每 30 秒后我调用获取消息服务(为此我使用了线程计时器)并且在收到来自服务器的消息后重新加载数据调用所有数据显示在表格 View 中当键盘不可见时这一切正常但是当键盘出现并等待服务器响应时重新加载数据我的应用程序崩溃并给出以下错误消息。
void _WebThreadLockFromAnyThread(bool), 0xc849490: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
bool _WebTryThreadLock(bool), 0xc849490: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now.
最佳答案
我的问题是解决我试图通过辅助线程在 TableView 中重新加载数据。
这就是我所做的
[self performSelectorOnMainThread:@selector(myMethod) withObject:nil waitUntilDone:NO]; And My problem is solved
关于objective-c - WebTry线程锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7161361/