tags:

views:

67

answers:

2

I need to parse the response header information and handle the status code.I got the html response string now i need to do parsing how to do in iPhone?

A: 

Look for the following in the documentation:

  • NSString componentsSeparatedByString:
  • NSString componentsSeparatedByCharactersInSet:
  • NSScanner class
Adam Woś
A: 

If you are using NSURLConnection for HTTP calls you can get the HTTP response code and headers from the NSURLConnectionDelegate methods as follows:

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
    NSInteger statusCode = [httpResponse statusCode];
    NSDictionary* headers = [httpResponse allHeaderFields];
}
cidered