I am not able to get the HTML source code when I try to request this URL: http://www.google.co.in/search?q=search
NSURL *url = [NSURL URLWithString:@"http://www.google.co.in/search?q=search"];
NSMutableURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
NSLog(@"Webdata : %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
The data is always NULL.
This works:
But if you need to use a NSURLConnection you should use it asynchronously and implement the willSendRequest method to handle redirection.