【问题标题】:Result of call to finalizeStatusForAccount is Unused in swift 3调用 finalizeStatusForAccount 的结果在 swift 3 中未使用
【发布时间】:2018-02-10 11:37:13
【问题描述】:

self.coreDataStack.finalizeStatusForAccount(currentAccount, fromStatus: ObjectStatus.tempClear, toStatus: ObjectStatus.clear)
self.coreDataStack.finalizeStatusForAccount(currentAccount, fromStatus: ObjectStatus.tempGreen, toStatus: ObjectStatus.green)

我收到这两个警告,谁能建议如何删除这些警告

【问题讨论】:

标签: ios swift core-data swift3


【解决方案1】:

警告说函数 finalizeStatusForAccount 返回一个值,但你没有使用它。您可能希望将返回值分配给变量,如下所示:

let returnValue = self.coreDataStack.finalizeStatusForAccount...

或者如果你知道你不需要检查返回值,你可以这样写:

let _ = self.coreDataStack.finalizeStatusForAccount...

后者是 Swift 中的标准模式。

【讨论】:

    【解决方案2】:

    如果这是您的函数finalizeStatusForAccount,您可以这样添加@discardableResult

    @discardableResult
    func finalizeStatusForAccount() -> Any {
        return 100500
    }
    

    【讨论】:

      猜你喜欢
      • 2017-03-02
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多