views:

61

answers:

2

I have a question for you about iPhone programming. I am building an app where I show the closest specialty restaurants to the user. I am using a navigation based application to do the development.

  1. I want to let the user press a button on the first screen that allows him/her to go to screen 2.

  2. From screen 2, here the user will see a table of all the restaurants close to the user.

  3. Once the user selects a restaurant from this table, the user is taken to a third screen

  4. Here, the user will see a map where the user will see where he/she is, and where the restaurant is located.

I will be using the CoreLocation framework to initially calculate the user's location, and then use this to search the database for locations close by. What I am confused about is, what method should I be doing this in the RootViewController? Would I place the button in the viewDidLoad() method, which would then trigger the

-(void)locationManager: (CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
                                                            fromLocation:(CLLocation *)oldLocation

method? Does this make sense?

Any suggestions?

Thanks in advance to all who reply.

A: 

I'd create a singleton class named for instance CurrentLocationProvider with all the logic connected with updating location incapsulated inside it and call it's beginUpdateLocation method in AppDelegate. It will be also great to provide user with a button that updates location explicitly when fired.

NR4TR
A: 

There are a few different ways to do this.

  1. Use a UITabBarController with three tabs, one for each of your views. When you want to auto-transition to the next screen, use [myTabBarController setSelectedIndex:] or [myTabBarController setSelectedViewController:].

  2. Pattern it after a flip-view "Utility Application." You can create a project using the Utility Application template for example code. The major difference is that instead of flipping from the backside to the front side, you're flipping to a third view controller.

  3. Use a UINavigationController and pushViewController:animated: the second and third view controllers.

The actual CLLocationManagerDelegate stuff should probably live it the app delegate. Let the app delegate manage "global" data for the app.

John Franklin
Thanks very much for your response. The app I am trying to emulate is www.timmyme.com which shows you the closest "Tim Horton's" coffee shop to you. Which approach would be best to accomplish this?
syedfa
I'd go with a TabBarController based app. One tab for the map, one tab for the listing, and maybe one for filter settings like "has WiFi" or "has drive-thru." (I don't know this chain, these may not be relevant.)
John Franklin