It is very likely that the request is not working and the response object is not created. You can check it as follows:
if (response) { NSHTTPURLResponse* newResp = (NSHTTPURLResponse*)response; NSLog(@"%d", newResp.statusCode); } else { NSLog(@"No response received"); }
As suggested by another commenter, you should probably include an NSError object so that you can more efficiently check for errors:
NSHTTPURLResponse *response=nil; NSError *error = nil; NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: &error];
Then you can check the error before checking the response:
if (error) { NSLog(@"Error sending request: %@", [error localizedDescription]); }
source share