Synchronous Request
suggest changesendSynchronousRequest blocks the thread that calls it. Do not call it on the main thread. It was deprecated in iOS 9. App Transport Security blocks this http URL. URLWithString: is nil for a string that is not a URL.
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]];
NSURLResponse * response = nil;
NSError * error = nil;
NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
if (error == nil)
{
// Parse data here
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents