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

简介: 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)
                }
            }
        }


目录
相关文章
|
8月前
|
Java
You may wish to exclude one of them to ensure predictable runtime behavior
You may wish to exclude one of them to ensure predictable runtime behavior
65 1
|
3月前
|
Java
Unable to obtain OffsetDateTime from TemporalAccessor: {},ISO resolved to 2024-11-26T20:55:26 of type java.time.format.Parsed
Unable to obtain OffsetDateTime from TemporalAccessor: {},ISO resolved to 2024-11-26T20:55:26 of type java.time.format.Parsed
97 0
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
662 0
Error: Plugin/Preset files are not allowed to export objects, only functions……
Error: Plugin/Preset files are not allowed to export objects, only functions……
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
367 0
|
网络协议 关系型数据库 Linux
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
204 0
|
Go Windows 开发工具
解决golang windows调试问题:Could not determine version number: could not find symbol value for runtime.buildVersion
版本信息: go:1.8.3 windows: win7/64 idea-go-plugin:171.4694.61 在windows下,使用dlv进行调试的时候,如果golang程序引入了c模块,比如常用的sqlite模块,那么在调试的时候一定会发生这个错误: · Could not determine version number: could not find symbol value for runtime.buildVersion· 现在这个问题已经解决了,解决方法就是go build 的时候加入-ldflags="-linkmode internal" ,这样就可以正常调试了。
2196 0
|
持续交付 jenkins Java
&#39;version&#39; contains an expression but should be a constant
[WARNING] Some problems were encountered while building the effective model for com.app:cache:jar:4.
6132 0