崩溃提示在子线程中更新了UI

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'

bug提示如上,定位代码的方式

Edit scheme ——> Run ——> Diagnostics

勾选:Main Thread Checker
运行!

if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {
            // main
            
        } else {
            dispatch_async(dispatch_get_main_queue(), ^{
               
            });
        }

你可能感兴趣的:(崩溃提示在子线程中更新了UI)