is there an easy way to get the http status code in the failure block from AFHTTPClient?

前端 未结 6 1752
猫巷女王i
猫巷女王i 2020-12-13 01:05

I see that there is a list of accepted http status codes that I can modify, but I think it would be cleaner if I can get the http status code in the failure block ..

6条回答
  •  别那么骄傲
    2020-12-13 01:45

    In newer versions of AFNetworking, you can retrieve the response object from the error:

    [[[error userInfo] objectForKey:AFNetworkingOperationFailingURLResponseErrorKey] statusCode]
    

    This is handy if you're doing error handling further up the line and don't want to pass around the response object.

提交回复
热议问题