gpt4 book ai didi

ios - 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因 : 'threading violation: expected the main thread'

转载 作者:行者123 更新时间:2023-11-29 05:08:14 26 4
gpt4 key购买 nike

我的应用程序正在使用第三方库,并且在某些设备(例如 iOS 13.3)上发生崩溃

尝试在主线程上调用该方法

Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation] PID: 1496, TID: 390696, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0

2020-01-28 12:31:47.733875+0000 My BT Gotham[1496:390696] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'

尝试在后台线程上调用该方法

这是错误

  • Assertion failure in -[FBSSerialQueue assertOnQueue], /BuildRoot/Library/Caches/com.apple.xbs/Sources/FrontBoardServices/FrontBoard-626.4.1/FrontBoardServices/FBSSerialQueue.m:98 2020-01-28 17:23:47.972336+0000 My BT Gotham[1773:459656] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'

仅供引用:我总是在后台线程上使用 API 方法,它在大多数设备上都能正常工作,但我上面引用的问题仅在某些设备上有效。

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
[LibObj model_Method:self];
});

最佳答案

正如它所显示的,您正在从后台调用 UI 方法...它应该类似于:

DispatchQueue.main.async {
// use your method...
}

但是,如果您的第三方库已经在幕后执行 DispatchQueue.main 调用,那么当您执行异步调用时,它可能会变得困惑......

关于ios - 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因 : 'threading violation: expected the main thread' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59954361/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com