How can I set the 30 sec timeout? NSURL
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [searchBar.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSError* error;
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
From this previous SO question timeout stringwithcontentsofurl
In this case, you might be best off using the
NSURLConnectionclass method+sendSynchronousRequest:returningResponse:error:;it’ll return a data object you can initialize your string with (using-initWithData:encoding:). You can specify a timeout by creating anNSURLRequestusing its-initWithURL:cachePolicy:timeoutInterval:method, then pass that request as the first parameter of+sendSynchronousRequest:returningResponse:error:.