Ios8 ios 8上不支持的URL

Ios8 ios 8上不支持的URL,ios8,nsurl,nsurlrequest,Ios8,Nsurl,Nsurlrequest,我正在尝试使用以下代码从google places获取json: NSString *query = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%i&types=%@&sensor=true&key=%@", center.latitude, center.longitude, rad, type

我正在尝试使用以下代码从google places获取json:

NSString *query = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%i&types=%@&sensor=true&key=%@", center.latitude, center.longitude, rad, types, kGOOGLE_API_KEY];
NSLog(@"%@",query);
NSURL *googleRequestURL=[NSURL URLWithString:query];
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:googleRequestURL] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
    if (error) {
        NSLog(@"Error fetching data: %@",[error description]);
    } else {
        //To-do
    }
}];
结果url为:

我的钥匙是出于淫秽的原因而丢失的

从我的笔记本电脑的浏览器中可以正常工作,但返回错误:

Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x7fe47bc138f0 {NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x7fe47be9dbe0 "unsupported URL"}
我尝试在浏览器中使用http而不是https,它返回json并显示一些错误消息,但仍然返回一些内容,但没有成功


我做错了什么?

这就是我解决问题的方法。祝你好运

NSString *google = @"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%f,%f&radius=500&types=%@&key=%@";  
NSString *link = [NSString stringWithFormat:google, coordinate.latitude, coordinate.longitude, types, GOOGLE_KEY];
NSURL *url = [NSURL URLWithString:[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];  
NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:url];

我就是这样解决的。祝你好运

NSString *google = @"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%f,%f&radius=500&types=%@&key=%@";  
NSString *link = [NSString stringWithFormat:google, coordinate.latitude, coordinate.longitude, types, GOOGLE_KEY];
NSURL *url = [NSURL URLWithString:[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];  
NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:url];

谢谢,逃逸百分比部分已经足够了!谢谢,逃逸百分比部分已经足够了!