我是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