在iOS中,如何从Web服务器接收HTTP状态代码(404,500 200等)。我假设它在NSUrlConnectionDelegate中。

Objective-C或 Monotouch .NET回答确定。

最佳答案

是的,您可以在委托(delegate)方法-didRecieveResponse中获取状态代码:

- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
   NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
   int code = [httpResponse statusCode];
}

关于iphone - NSUrlConnectionDelegate-获取http状态代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6918760/

10-13 04:00