问题描述
我使用 NSURLConnection
和 NSURLRequest 课程。
如何读取响应的状态,即app引擎使用
response.set_status设置的值(200,message =Success)
例如?
How do I read the response's status, i.e. the value set by app engine using
response.set_status(200, message="Success")
for instance?
收到
委托客户端的委托。 NSURLConnection的
<$ c后,我无法找到可以读取这些状态代码的位置$ c> connectionDidFinishLoading
I'm not able to find where I can read these status codes once I receive the NSURLConnection's
connectionDidFinishLoading
delegate call on the client end.
推荐答案
connection:didReceiveResponse:
在收到响应时调用delegate方法,这会给你一个 NSURLResponse
来玩。
The connection:didReceiveResponse:
delegate method is called when a response is received, which gives you an NSURLResponse
to play with.
如果您发出了HTTP请求,那么它实际上是一个 NSHTTPURLResponse
对象,它有一个 statusCode
方法。
If you've made an HTTP request, then it'll actually be an NSHTTPURLResponse
object, which has a statusCode
method.
这篇关于如何从iOS检查http请求响应状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!