I am trying to display a list of location searchs into a TableView, first of all is this possible?
If so how would i go about this?
My code to gather the list is:
MKLocalSearchRequest *searchRequest = [[MKLocalSearchRequest alloc] init];
[searchRequest setNaturalLanguageQuery:@"Cafe"];
CLLocationCoordinate2D userCenter = CLLocationCoordinate2DMake(48.8566, 2.3522);
MKCoordinateRegion userRegion = MKCoordinateRegionMakeWithDistance(userCenter, 15000, 15000);
[searchRequest setRegion:userRegion];
MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:searchRequest];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
if (!error) {
NSMutableArray *gLoc = [NSMutableArray array];
for (MKMapItem *mapItem in [response mapItems]) {
[gLoc addObject:mapItem.placemark];
NSLog(@"Name: %@, Placemark title: %@", [mapItem name], [[mapItem placemark] title]);
In the above example I am searching for "Cafe" in Paris, and storing the information into an Array called gLoc.
The contents of :
NSLog(@"Name: %@, Placemark title: %@", [mapItem name], [[mapItem placemark] title]);
Is a complete list of all locations formatted as:
Name: Strada Café, Placemark title: 94 Rue du Temple, 75003 Paris, France
The contents of :
NSLog(@"%@", gLoc);
Is array with all locations formatted as:
"Strada Caf\U00e9, 94 Rue du Temple, 75003 Paris, France @ <+48.86220020,+2.35731150> +/- 0.00m, region CLCircularRegion (identifier:'<+48.86220020,+2.35731150> radius 49.91', center:<+48.86220020,+2.35731150>, radius:49.91m)",
I'm stumped on how to continue. I was looking to turn this information into the name as a title and address as subtitle ideally, is there a way to manipulate the data in such a way to achieve this?