我怎样才能得到响应数据?
How can i get the response data?
我不知道如何使用响应数据。我尝试将它添加到字典中,但是当我打印它时,我得到:
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)
}
)
您可以使用如下字典的响应。
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;
}
我不知道如何使用响应数据。我尝试将它添加到字典中,但是当我打印它时,我得到:
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)
}
)
您可以使用如下字典的响应。
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;
}