美文网首页
Swift错误提示解决办法--Swift Compiler Er

Swift错误提示解决办法--Swift Compiler Er

作者: 半缘魔君 | 来源:发表于2017-03-22 14:24 被阅读0次

    错误提示:

    Swift Compiler Error

      '?' must be followed by a call, member lookup, or subscript
    

    报错代码:

    错误代码.png

    解决办法:
    将代码行 head.backgroundColor = UIColor.hex2RGB("#e9f1f6")
    改为:
    head.backgroundColor = UIColor.hex2RGB("#e9f1f6") as UIColor

    总结:

    将代码: head.backgroundColor = UIColor.hex2RGB("#e9f1f6")分开发现不报错了....

    Paste_Image.png

    注: 为UIColor的增加的OC分类,放在swift里,返回值就变成了可选值,尤其是在闭包里,这个问题属于编译器的问题

    相关文章

      网友评论

          本文标题:Swift错误提示解决办法--Swift Compiler Er

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