Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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()
            }
        })
like image 217
ios killers Avatar asked Sep 26 '15 09:09

ios killers


2 Answers

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

like image 59
vadian Avatar answered Nov 05 '22 21:11

vadian


I had the Same Problem in my project. i just changed my code from let parameters = ["email": mail,"password":passCode ] to let parameters = ["email": mail as! AnyObject,"password":passCode as! AnyObject] . Not sure if it affects anything else.

like image 40
Joker Avatar answered Nov 05 '22 20:11

Joker