bool _WebTryThreadLock(bool), 0xf0d4e50:

本文详细解析了一次Swift编程中在非主线程更新UI导致程序崩溃的问题,通过崩溃日志分析,揭示了问题所在,并解释了错误原因。文章最后指出错误发生在尝试在次要线程获取web锁时,以及对搜索代理方法的误用导致的崩溃。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

崩溃信息打印:

2014-01-17 17:36:47.932 BuyBuyring[32900:9413] bool _WebTryThreadLock(bool), 0xf0d4e50: 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...
1   _ZL17_WebTryThreadLockb
2   WebThreadLock
3   -[UITextRangeImpl isEmpty]
4   -[UITextRange(UITextSelectionAdditions) _isCaret]
5   -[UITextSelectionView setCaretBlinks:]
6   -[UIKeyboardImpl setCaretBlinks:]
7   -[UIKeyboardImpl setDelegate:force:]
8   -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
9   -[UINavigationController navigationTransitionView:didStartTransition:]
10  -[UINavigationTransitionView transition:fromView:toView:]
11  -[UINavigationTransitionView transition:toView:]
12  -[UINavigationController _startTransition:fromViewController:toViewController:]
13  -[UINavigationController _startDeferredTransitionIfNeeded]
14  -[UINavigationController pushViewController:transition:forceImmediate:]
15  -[UINavigationController pushViewController:animated:]
2014-01-17 17:36:48.114 BuyBuyring[32900:707] (
        {
        merchant =         (
        );
        product = "<ProductItem: 0xf028d30>";
    }
)
16  -[RootViewController searchDelegateMetod:]
17  -[NSThread main]
18  __NSThread__main__
19  _pthread_start
20  thread_start
(lldb)

刚开始不知道这是什么原因,百度了一下,说是在线程中更新了UI界面,崩溃在这里(下图):











然后在调用searchdelegate的方法那里发现自己写错了(粗心啊),本来想要写下面的第一段代码,竟写成了第二段代码:

[self.delegate performSelector:@selector(searchDelegateMetod:) withObject:[dataarray objectAtIndex:indexPath.row]];

[self.delegate performSelectorInBackground:@selector(searchDelegateMetod:) withObject:[dataarray objectAtIndex:indexPath.row]];

所以就出现上面的错误了,呵呵

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值