0

Im trying to open Maps from my App from a table view cell, I know I need this code in my AppDelegate.m file:

UIApplication *app = [UIApplication sharedApplication];

[app openURL:[NSURL URLWithString:@"https://maps.google.com.au/maps?q=Our+Lady+Queen+of+Peace+Catholic+Church+Greystanes"

I would like the saddr to be the user's and direct to the location address as above.

How do I link a table view cell to that code ?

1 Answers1

0

You would do this inside the didSelectRowAtIndexPath in the ViewController that controls that TableView (not in the AppDelegate). Build that url with the data you need in that cell (hopefully coming from a backing data source) and then use the code you have above. Something like this:

NSDictionary *thisCell = [myTableViewData objectAtIndex:indexPath.row];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com.au/maps?q%@", [thisCell valueForKey:@"locationKey"]]]];
LJ Wilson
  • 14,445
  • 5
  • 38
  • 62
  • Hi, I'm very new to developing Apps would you be able to describe this in more detail. how do I access the viewController that controls the TableView, it is not in the viewController.m so where do I find it ? – Ben Williamson Aug 20 '12 at 10:38
  • What part of your application displays a tableview? That "scene" would have a view controller (or a tableview controller) backing it. Do you have a tablieview somewhere in your application right now? – LJ Wilson Aug 20 '12 at 10:41
  • Yes I can locate the tableView and tableview Controller in mainstoryboard.storyboard – Ben Williamson Aug 20 '12 at 10:45
  • You need to have a custom class as the parent of that TableView. You would then set that to be the parent of your Storyboard scene TableViewController. – LJ Wilson Aug 20 '12 at 12:45
  • If all this is foreign to you, you really need to take an Intro to iOS development course of some kind. The Stanford one (on iTunesU) is a great choice assuming you already have a development background in some other object oriented language. – LJ Wilson Aug 20 '12 at 13:08