문제

I'm using latest AFNetworking for my app which speaks with REST API server.

When I get some 500 error from it with JSON body something like

{ "message": "my error message" },

I cannot retrieve this message from NSError which lib responds to me:

[api setupUser:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
   // some success handle
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
   // cannot get json response of error :(
}];

How do you workaround it?

도움이 되었습니까?

해결책

The answer was simple - operation.responseObject in failure callback contains json data as well. Sweet ^.^

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top