【问题标题】:Swift 3 syntax error (Backendless)Swift 3 语法错误(无后端)
【发布时间】:2016-09-19 06:35:02
【问题描述】:

更新我的 Xcode 后,我在 backendless 的查找语法中遇到错误,例如

   dataStore.find(
        { (result: BackendlessCollection!) -> Void in
            let contacts = result.getCurrentPage()
            for obj in contacts {
                print("\(obj)")
            }
        },
        error: { (fault: Fault!) -> Void in
            print("Server reported an error: \(fault)")
    })

错误是:Cannot convert value of type '(BackendlessCollection!) -> Void' to expected argument type '((BackendlessCollection?) -> Void)!'

我该如何解决???

【问题讨论】:

  • 编译器建议将(result: BackendlessCollection!) -> Void替换为((result: BackendlessCollection?) -> Void)!
  • 哦,好吧,告诉我一些我不知道的事情,我该怎么做?
  • 用其他代码替换代码有什么不清楚的地方?
  • (result: BackendlessCollection?) 喜欢这样吗? @vadian
  • 将左侧的整个表达式替换为右侧的整个表达式。

标签: swift3 xcode8 backendless


【解决方案1】:

将代码替换为

dataStore?.find(
        { (result: BackendlessCollection?) -> Void in
            let contacts = result?.getCurrentPage()
            for obj in contacts! {
                print("\(obj)")

            }
        },
        error: { (fault: Fault?) -> Void in
            print("Server reported an error: \(fault)")
    })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-26
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多