在Android中,我们可以在HTTP客户端中使用getReasonPhrase()
:
HttpResponse response = httpClient.execute(getRequest);
System.print.out(response.getStatusLine().getReasonPhrase());
可以是
ok
,Not Found
,Created
或Web Service中的任何内容。我们如何在Objective-C中获得它?
这是我可以收到
status Code
的方式:NSURLResponse *resp
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)resp;
int responseStatusCode = [httpResponse statusCode];
NSLog(@"%i", responseStatusCode);
getReasonPhrase()
怎么样? 最佳答案
NSString *reasonString = [NSHTTPURLResponse localizedStringForStatusCode:responseStatusCode];
干杯