Cannot convert value of type '[String : String?]' to expected argument type '[NSObject : AnyObject]?'

ios killers picture ios killers · Sep 26, 2015 · Viewed 14.3k times · Source

When I use Parse 1.8.5 to upload data to Parse, this cloud code has compile error in "params" that I cannot debug it.

       let params = ["phoneNumber" : userPhoneNumber, 
                    "username": username,
                    "password": userPassword,
                    "Email": userEmail
                     ]  

        PFCloud.callFunctionInBackground("sendCode", withParameters: params, block: 
              { (response: AnyObject?, error: NSError?) -> Void in
            if response?.localizedDescription != nil {
                print(error)
                var alert = UIAlertView(title: "Failure", message: "SignUp Error", delegate: self, cancelButtonTitle: "OK")
                alert.show()
            } else {
                self.activityIndicator.stopAnimating()
            }
        })

Answer

vadian picture vadian · Sep 26, 2015

The error message says that there are optional types in the values of params.
Make sure that all values are unwrapped.