我有一个连接方法。我想在线程中使用它,因为它需要很长时间。但是这种方法会触发其他许多方法,所以我会收到类似上面的错误消息。
* _WebThreadLockFromAnyThread(bool), 0x94316f0:从主线程或web线程以外的线程获取web lock。不应从辅助线程调用 UIKit。*
我的代码是:
    __weak LoginViewController *weakSelf = self;
    dispatch_queue_t connectionQueue = dispatch_queue_create("connection Queue", NULL);
    dispatch_async(connectionQueue, ^{
        [weakSelf connect];
        dispatch_async(dispatch_get_main_queue(), ^{
            [spinner stopAnimating];
        });
    });