Reputation: 6465
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.
Upvotes: 7
Views: 14679
Reputation: 27345
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]
Upvotes: 12