I have created following method in my code:
func SignIn(objDictionary:Dictionary<String,String>)
{
//Body of method
}
I need to pass the following dictionary as a parameter in this method which is defined below:
let objSignInDictionary:Dictionary = ["email":emailTextField.text, "password":passwordTextField.text]
How can I pass this dictionary in the above method as a parameter?
This should be noted that method is in another class and I am calling the method by creating its object as follows:
let obj = Services()
SignIn is defined in Services.swift class so I am trying to call it like
obj.SignIn(objSignInDictionary)
but getting following error
"String!" is not identical to "String"
Where I am wrong and how it can be fixed. I am stuck here since couple of days.
If you alt+click objSignInDictionary
in Xcode you will see its inferred as [String : String!]
. You can fix this by explicitly setting objSignInDictionary
type:
let objSignInDictionary:[String:String] = ["email":emailTextField.text, "password":passwordTextField.text]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With