我是iOS编程新手。我的要求是将Google地方的自动填充请求设置为UITextField
。 我写的代码如下如何在iOS中将自动完成请求设置为UITextField
NSString *urlPath = [NSString stringWithFormat:@"/maps/api/place/autocomplete/json?input=%@&types=geocode&language=en-EN&sensor=false",string];
NSURL *url = [[NSURL alloc]initWithScheme:@"http" host:@"maps.googleapis.com" path:urlPath];
NSLog(@"url is:::%@",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
NSURLResponse *response ;
NSError *error;
NSData *data;
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"data is:::%@",data);
NSMutableDictionary *jsonDict= (NSMutableDictionary*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"jsonDict is:%@",jsonDict);
但它给空。你能告诉我我错在哪里吗?
被警告,这不适用于迅速 – Anconia