Bir kullanıcının arka uçuma karşı kimlik doğrulaması yapmak için bu sınıfa sahibim. Swift: Geri arama işlevine tuple iletmeye çalışırken "belirsiz ifade" alma
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)
}
}
}
}
success(response)
ben
Type of expression is ambiguous without more context
alıyorum. Herhangi bir fikir?
Bu dersi yazmak için daha iyi, daha Swifty bir yolu var mı?
beyan yanıt izin 'olarak cevap: (res: NSHTTPURLResponse, json: JSON statusCode: httpStatus) = (res: res, json: JSON (json!), statusCode: httpStatus) 'daha fazla bilgi atar mı görmek – gabuh
Tuple üye isimlerini devirmeyi deneyin. – mattt