在下载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中的更新有关,但我找不到任何表明这一点的东西。任何与此问题的帮助将不胜感激。

最佳答案

代替NSError,使用Error

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


这对我有用。

07-24 09:38
查看更多