I am using this method to get suggestions and i need to show them in tableview:
- (void)placeAutocomplete:(NSString *)autoCompleteString {
[self.autoCompleteSuggestionsList removeAllObjects];
GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init];
filter.type = kGMSPlacesAutocompleteTypeFilterCity;
[_placesClient autocompleteQuery:(NSString *)autoCompleteString
bounds:nil
filter:filter
callback:^(NSArray *results, NSError *error) {
if (error != nil) {
NSLog(@"Autocomplete error %@", [error localizedDescription]);
return;
}
for (GMSAutocompletePrediction* result in results) {
//NSLog(@"Result '%@' with placeID %@", result.attributedFullText.string, result.placeID);
//NSRange autoCompleteRange = [result.attributedFullText.string rangeOfString:autoCompleteString];
//if (autoCompleteRange.location == 0) {
//NSString *stringNow = [NSString stringWithFormat:@"%@",result.attributedFullText.string];
[self.autoCompleteSuggestionsList addObject:result.attributedFullText.string];
//NSLog(@"test : %@",stringNow);
//NSLog(@"%@",self.autoCompleteSuggestionsList);
//}
}
}];
[self.autocompleteTableView reloadData];
NSLog(@"%@",self.autoCompleteSuggestionsList);
}
but I cannot access the results outside of the autocompleteQuery method
when logged it shows correctly inside the method but not outside , I am using mutable array to access it but i shows correctly inside but not outside.
I don't need suggestions for using any third party autocomplete pod . I am getting the result i just need them to be accessed from the method so that it could be accessible to show the tableview as well