0

Prior to downloading Xcode 8 I was able to perform functions from the Particle iOS Cloud SDK (Spark SDK) without any problem. Now, I am being given multiple errors all similar to the ones below.

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)

            }

        }

Error: Cannot convert value of type '(NSError?) -> Void' to expected argument type '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()

            }

        }

    }

Error: Cannot convert value of type '([AnyObject]?, NSError?) -> Void' to expected argument type '(([Any]?, Error?) -> Void)?'

I've tried updating my Podfile and toying with the function calls but nothing seems to work. I'm wondering if it has something to do with the updates in Swift 3.0 but I can't find anything that would indicate so. Any help with this issue would be much appreciated.

Petey
  • 1
  • 2

1 Answers1

2

Instead of NSError, use Error:

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

This did the trick for me.

Dan Lee
  • 21
  • 2