线程崩溃

代码写作中碰到了这样一个情况,block回调时,控制台打印了这样的信息。

This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
 Stack:(
	0   Foundation                          0x0000000181fdc424 <redacted> + 96
	1   Foundation                          0x0000000181dd6ad4 <redacted> + 76
	2   Foundation                          0x0000000181dd69e8 <redacted> + 120
	3   Foundation                          0x0000000181dd6794 <redacted> + 112
	4   UIKit                               0x000000018b0969d0 <redacted> + 2152
	5   QuartzCore                          0x000000018560be54 <redacted> + 184
	6   QuartzCore                          0x000000018560ffe4 <redacted> + 324
	7   QuartzCore                          0x000000018557c6c8 <redacted> + 320
	8   QuartzCore                          0x00000001855a41b0 <redacted> + 580
	9   QuartzCore                          0x00000001855a5030 <redacted> + 92
	10  CoreFoundation                      0x000000018142a910 <redacted> + 32
	11  CoreFoundation                      0x0000000181428238 <redacted> + 412
	12  CoreFoundation                      0x0000000181348dc8 CFRunLoopRunSpecific + 584
	13  WebCore                             0x000000018960c2d4 <redacted> + 592
	14  libsystem_pthread.dylib             0x00000001810a9220 <redacted> + 272
	15  libsystem_pthread.dylib             0x00000001810a9110 <redacted> + 0
	16  libsystem_pthread.dylib             0x00000001810a7b10 thread_start + 4
)

查看之后,发现是由于线程操作不当导致的,在子线程中执行了 popViewControllerAnimated: 操作,

修改为

dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf.navigationController popViewControllerAnimated:YES];
        });

重新调试之后,没有再出现上述打印信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值