现在调用AFNetworking
的{{1}}方法中的失败块。并且可以访问POST
。
我需要从服务器访问响应。我希望字典像这样:
NSURLSessionDataTask
但我不知道在哪里寻找这个?可以使用{ "error": "sth written on the backend" }
和AFHTTPRequestOperation
。
使用 AFNetworking 3.0
示例:
AFNetworking 2.0
答案 0 :(得分:0)
所有内容都包含在if let responseData = error?.userInfo[NSString(string: AFNetworkingOperationFailingURLResponseDataErrorKey)] as? NSData {
do {
if let response = try NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.AllowFragments) as? [String: AnyObject] {
//do sth with your response
}
} catch {
//handle the exception
}
}
对象中:
{{1}}