私はこのクラスを使って、バックエンドに対してユーザーを認証します。 success(response)
でSwift:タプルをコールバック関数に渡すときに「あいまいな表現」を得る
class BackendService {
class func performLogin(#email: String, password: String, success:((res: NSHTTPURLResponse, json: JSON, statusCode: HTTPStatus))->(), failure: (NSError)->()) {
let loginURL = baseURL + "/login"
let parameters = ["email": email, "password": password]
Alamofire.request(.POST, loginURL, parameters: parameters).responseJSON { (req, res, json, err) in
if(err != nil) {
let response = (error: err!)
failure(response)
}
else {
if let httpStatus = HTTPStatus(rawValue: res!.statusCode) {
let response = (res: res, json: JSON(json!) , statusCode: httpStatus)
success(response)
}
}
}
}
私はType of expression is ambiguous without more context
を取得しています。何か案は?
このクラスを書くには、より良い、より賢い方法がありますか?
宣言応答をさせ 'として応答(RES:NSHTTPURLResponse、JSON:JSON、からstatusCode:はhttpStatus)=( res:res、json:JSON(json!)、statusCode:httpStatus) 'それが詳細をスローするかどうかを確認する – gabuh
タプルメンバー名を削除してみてください。 – mattt