ios - get responseObject on failure block AFNetworking 3.0 -


how can response string failure block in afnetworking 3.x,

in 2.x version way was:

[manager get:path parameters:parameters success:^(afhttprequestoperation *operation, id responseobject) {     nsdictionary *dictionary_fetchresult = responseobject; } failure:^(afhttprequestoperation *operation, nserror *error) {     nsdictionary *dictionary_fetchresult = operation.responseobject; }]; 

but in 3.x version there no operation in returning block's parameter shown below:

[manager post:path parameters:parameters progress:^(nsprogress * _nonnull uploadprogress) {         } success:^(nsurlsessiondatatask * _nonnull task, id  _nullable responseobject) {     nsdictionary *dictionary_fetchresult = responseobject; } failure:^(nsurlsessiondatatask * _nullable task, nserror * _nonnull error) {     nslog(@"error: %@", error); }]; 

so hoping if able achieve that.

just in failure block:-

 nsstring* errresponse = [[nsstring alloc] initwithdata:(nsdata *)error.userinfo[afnetworkingoperationfailingurlresponsedataerrorkey] encoding:nsutf8stringencoding]; nslog(@"%@",errresponse); 

for swift:-

var errresponse: string = string(data: (error.userinfo[afnetworkingoperationfailingurlresponsedataerrorkey] as! nsdata), encoding: nsutf8stringencoding) nslog("%@", errresponse) 

Comments