【发布时间】:2016-01-20 18:21:08
【问题描述】:
我定义了下面的列表 swift 类,并尝试从视图控制器调用 sfAuthenticateUser。但是 Xcode 智能感知列出了错误的参数类型,而不是我定义的类型。
错误:无法将“字符串”类型的值转换为预期的参数类型“APISFAuthentication”
Xcode 版本 7.1 (7B91b)
//ViewController方法调用如下
@IBAction func ActionNext(sender: AnyObject) {
let sss = APISFAuthentication.sfAuthenticateUser(<#T##APISFAuthentication#>)
}
// 类定义如下
class APISFAuthentication {
init(x: Float, y: Float) {
}
func sfAuthenticateUser(userEmail: String) -> Bool {
let manager = AFHTTPRequestOperationManager()
let postData = ["grant_type":"password","client_id":APISessionInfo.SF_CLIENT_ID,"client_secret":APISessionInfo.SF_CLIENT_SECRET,"username":APISessionInfo.SF_GUEST_USER,"password":APISessionInfo.SF_GUEST_USER_PASSWORD]
manager.POST(APISessionInfo.SF_APP_URL,
parameters: postData,
success: { (operation, responseObject) in
print("JSON: " + responseObject.description)
},
failure: { (operation, error) in
print("Error: " + error.localizedDescription)
})
return true;
}
}
【问题讨论】: