我在我的代码中创建了以下方法:
func SignIn(objDictionary:Dictionary<String,String>)
{
//Body of method
}
Run Code Online (Sandbox Code Playgroud)
我需要将以下字典作为参数传递给此方法,该方法定义如下:
let objSignInDictionary:Dictionary = ["email":emailTextField.text, "password":passwordTextField.text]
Run Code Online (Sandbox Code Playgroud)
如何将上述方法中的字典作为参数传递?
应该注意的是,方法在另一个类中,我通过创建其对象来调用该方法,如下所示:
let obj = Services()
Run Code Online (Sandbox Code Playgroud)
SignIn是在Services.swift类中定义的,所以我试着把它称为
obj.SignIn(objSignInDictionary)
Run Code Online (Sandbox Code Playgroud)
但得到以下错误
"String!" is not identical to "String"
Run Code Online (Sandbox Code Playgroud)
我错在哪里以及如何解决它.我几天都被困在这里.