【问题标题】:Unable to perform functions from Particle iOS Cloud SDK after downloading Xcode 8 / Swift 3.0下载 Xcode 8 / Swift 3.0 后无法从 Particle iOS Cloud SDK 执行功能
【发布时间】:2016-09-12 23:25:18
【问题描述】:

在下载 Xcode 8 之前,我能够毫无问题地从 Particle iOS Cloud SDK (Spark SDK) 执行功能。现在,我收到了多个错误,都类似于下面的错误。

SparkCloud.sharedInstance().loginWithUser(username!, password: password!) { (error:NSError?) -> Void in

            // Deactivates activity indicator.
            activityIndicator.stopAnimating()

            // Reallows interaction events.
            UIApplication.sharedApplication().endIgnoringInteractionEvents()

            if error != nil {

                Utils.showAlertOnVC(self, title: "Invalid parameters.", message: "Please try again.")
                self.clearText()

            } else {

                self.performSegueWithIdentifier("loginUser", sender: self)

            }

        }

错误:无法将类型“(NSError?)-> Void”的值转换为预期的参数类型“SparkCompletionBlock?”

SparkCloud.sharedInstance().getDevices { (sparkDevices: [AnyObject]?, error: NSError?) -> Void in

        if let sparkDevices = sparkDevices as? [SparkDevice] {

            for device in sparkDevices {

                self.myPhotons.append(device)
                self.tableView.reloadData()

            }

        }

    }

错误:无法将类型 '([AnyObject]?, NSError?) -> Void' 的值转换为预期的参数类型 '(([Any]?, Error?) -> Void)?'

我尝试更新我的 Podfile 并玩弄函数调用,但似乎没有任何效果。我想知道它是否与 Swift 3.0 中的更新有关,但我找不到任何表明这一点的东西。对此问题的任何帮助将不胜感激。

【问题讨论】:

    标签: ios cloud swift3 xcode8 particles


    【解决方案1】:

    用Error代替NSError:

    SparkCloud.sharedInstance().getDevices { (sparkDevices: [AnyObject]?, error: Error?)
    

    这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      相关资源
      最近更新 更多