美文网首页
2019-12-11

2019-12-11

作者: 红色小星 | 来源:发表于2019-12-11 18:57 被阅读0次
    • Swift闭包报错信息

    Function types cannot have argument labels; use '_' before 'cityName'

    错误代码:

    //    格式: typealias 闭包名称 = (参数名称: 参数类型) -> 返回值类型
    typealias callBackBlockGetCityName = (error:Error?,cityName:String?)->()
    

    原因

    闭包的入参的参数名需要去掉

    解决办法

    typealias callBackBlockGetCityName = (_ error:Error?,_ cityName:String?)->()
    
    
    • Weak报错信息

    'weak' must not be applied to non-class-bound 'WCInComeSourceContentViewDelegat

    解决办法

    // protocol前面 加上 @objc
    @objc protocol WCInComeSourceContentViewDelegate {
        
        func incomeSourceClick(view:WCInComeSourceContentView,index:Int)
        
    }
    
    

    Binary operator '>=' cannot be applied to two 'CGFloat?' operands
    为什么swift中两个CGFloat 不可以使用>=?
    需要转成 Double(value1) >=Double(value2) 就可以
    因为一个是可选 一个是不可选

    The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
    表达式做了太多东西,请拆开

    解决Xcode 的"Could not insert new outlet connection"问题
    重启Xcode OK

    相关文章

      网友评论

          本文标题:2019-12-11

          本文链接:https://www.haomeiwen.com/subject/gjjagctx.html