【发布时间】:2012-09-28 10:51:55
【问题描述】:
我在我的程序中使用 JSONKit 来解析 google places api,但我的应用程序崩溃并出现以下错误 -[NSURL _CFURLRequest]:无法识别的选择器发送到实例
NSString* URL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=28.632808,77.218276&radius=500&types=atm&sensor=false&key=AIzaSyDHft2g5IDshIpXS17uOtZzkqGGgj-p1RQ"];
NSError* error = nil;
NSURLResponse* response = nil;
NSURLRequest *URLReq = [NSURL URLWithString:URL];
//[request setURL:URL];
//[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
//[request setTimeoutInterval:30];
NSData* data = [NSURLConnection sendSynchronousRequest:URLReq returningResponse:&response error:&error];
if (error)
{
NSLog(@"Error performing request %@", URL);
NSLog(@"%@", [error localizedDescription]);
return;
}
NSDictionary *json = [data objectFromJSONData];
NSArray *places = [json objectForKey:@"results"];
NSLog(@"Google Data: %@", places);
【问题讨论】:
-
天哪……拜托,拜托,你不能在文档中阅读 what objects 方法返回吗?
标签: ios json nsurlconnection google-places-api jsonkit