The compiler is unable to type-check this expression in reasonable time; try breaking up the express

/Users/jiaguoshang/Downloads/OnlineShopDemo-master/SwiftOnlineShopDemo/SwiftOnlineShopDemo/ViewController/CFClassificationController/CFClassificationController.swift:66:53:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
在这里插入图片描述

This error generally occurs when a single expression is doing a lot of things. So compiler tells you to break it to sub-expressions.
一个单个的描述(判断条件)做了太多的事情。
老程序猿经常用这样语句来显示自己的水平多高,代码多精简。但是对有些程序猿理解不是那么一目了然。现代语言(js,swift,Kotlin),强类型的语言。可以做到言简意赅,类型推导,利于理解,不是增加理解的难度。 swift禁止这种耍大牌,直接给你编译不过。解决很简单:就是把它分成几个小语句替换了就可以了,也就是语句拆分。

        let y = rect.origin.y - leftTableView.mj_offsetY
        let h = leftTableView.mj_h - 44 * 3 - 1
        if y >= h {
            
            let contentOffset_y = leftTableView.mj_offsetY + 44 * 3
            
            if total_offset - leftTableView.mj_offsetY < 44 * 3 {
                //判断ios 11直接设置偏移无效,我也没弄懂,必须延时才有效
                
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
                    self.leftTableView.setContentOffset(CGPoint(x: 0, y: total_offset), animated: true)
                }

            }
            else
            {
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
                    self.leftTableView.setContentOffset(CGPoint(x: 0, y: contentOffset_y), animated: true)
                }
            }
        }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值