我不知道如何使用响应数据。我尝试将它添加到字典中但是当我打印它时我得到:
Swift.LazyForwardCollection,Swift.AnyObject>>
let manager = AFHTTPRequestOperationManager()
var params : Dictionary = ["username": user, "password": pass, "phone": numb]
manager.POST(
"http://happybakuapi.com/tehmin/api_evelazim/signup.php",
parameters: params,
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
println("JSON: " + responseObject.description)
var jsonResult = responseObject as! Dictionary<String, AnyObject>
println(jsonResult.values)
},
failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in
println("Error: " + error.localizedDescription)
}
)
答案 0 :(得分:1)
你可以使用字典的响应如下。
let manager = AFHTTPRequestOperationManager()
var params : Dictionary = ["username":"Aplle", "password": "asdsad", "phone": "919909999099"]
manager.POST("http://happybakuapi.com/tehmin/api_evelazim/signup.php",parameters: params,
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
println(responseObject)
println(responseObject.objectForKey("response"))
println(responseObject.objectForKey("error_type"))
println(responseObject.objectForKey("user_exist"))
},
failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in
println("Error: " + error.localizedDescription)
}
)
回复词典:
{
"error_type" = "user isset in database";
response = false;
"user_exist" = 1;
}