线程导致的崩溃
今天项目中用 [Object performSelectorInBackground:@selector(doSomething:) withObject:nil]开了个子线程,然后在这个线程中进行了一系列操作,结果发生了 bool _WebTryThreadLock(bool), 0x1498120: 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...
堆栈:
#0 0x3588eb7e in _WebTryThreadLock ()
#1 0x3588f2ce in _WebThreadAutoLock ()
这个问题 并导致了程序的崩溃。最后网上搜索,原来犯了一个小问题,子线程中不能进行UIKit相关的操作,必须用performSelectorOnMainThread方法回到主线程更新。
另外有时并不会抛出 bool _WebTryThreadLock(bool)这个异常,而直接崩溃抛出EXC_BAD_ACCESS。这个时候要是不仔细检查代码的话调试起来很难受
如有问题请大神指出