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

14,374

Solution 1

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

Solution 2

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.

Share:
14,374
Admin
Author by

Admin

Updated on July 18, 2022

Comments

  • Admin
    Admin almost 2 years

    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()
                }
            })