Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MarkSiu

macrumors newbie
Original poster
Jun 27, 2010
3
0
Hello,

I would like to get some information from a website. I have already got the HTML code of the website. However, I would like to get more header information of the website (e.g. http status code)

After read the apple library, I found that there are 2 methods which can display those information. However, I can only use one of the methods (has warning), another cannot be used.

The following is the code.

Code:
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSString *data=[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];

NSDictionary *responseAlllHeaderFields = [response allHeaderFields];
// how can I convent the NSDictionary to the NSString, I cannot use the NSLog to display the information
NSLog(responseAlllHeaderFields); // <-- wrong

// returns the HTTP status code for the response
NSInteger *responseStatusCode = [response statusCode];
// warning: initialization makes pointer from integer without a cast
NSLog(@"\nThe status code is %d\n", responseStatusCode);

Besides, are there are any other methods to get the header informatino?
Thank you very much.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.