Tried to obtain the web lock from a thread other than the main thread or the web thread. Crashing now

前端 未结 6 1406
轮回少年
轮回少年 2020-12-10 01:03

bool _WebTryThreadLock(bool), 0x8053ce0: 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 UI

6条回答
  •  醉梦人生
    2020-12-10 02:05

    This may be a result of calling to UIKit from a secondary thread. Crashing now...
    

    ...and as far as I can see that's just what you're doing. You're calling [alertProgress dismissWithClickedButtonIndex:0 animated:YES];, a UIKit method, from a thread other than your main thread(s), which is not allowed.

    For a very straight forward way to call back to the main thread if you can't use GCD, take a look at DDFoundation.

    Your code would in that case only change to do;

    [[alertProgress dd_invokeOnMainThread] dismissWithClickedButtonIndex:0 
                                           animated:YES]; 
    

提交回复
热议问题