【问题标题】:Swift 4 - expression was too complex to be solved in reasonable time swiftSwift 4 - 表达式太复杂,无法在合理的时间内迅速解决
【发布时间】:2017-10-18 22:59:55
【问题描述】:

我收到一个错误,即这个表达式太复杂,无法在 swift 4 上在合理的时间内解决 谁能帮帮我?

- AppDelegate.removeGIF(withURL: "images/" + self.currentUID + "/" + self.thisPostId + "." + self.currentGifExt)

【问题讨论】:

  • 使用字符串插值代替串联"images/\(self.currentUID)/\(self.thisPostId).\(self.currentGifExt)"

标签: ios swift xcode xcode9 swift4


【解决方案1】:

到目前为止,使用运算符是编译器类型检查最困难的事情

尝试使用字符串插值

AppDelegate.removeGIF(withURL: "images/\(self.currentUID)/\(self.thisPostId).\(self.currentGifExt)") 

或者,您可以只告诉编译器类型,这样它甚至不必进行类型检查。

let urlStr: String = "images/" + self.currentUID + "/" + self.thisPostId + "." + self.currentGifExt
AppDelegate.removeGIF(withURL: urlStr)

【讨论】:

    猜你喜欢
    • 2018-03-09
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多