views:

277

answers:

0

Here's my situation:

I have an app with 3 tabs. Tab 1 is a MKMapView. 2 is a navigation controller, with a table view, and 3 is going to be a table view with UI search bar or something different to the first two.

So, for my mapview, on viewDidLoad i want it to get the users current location, go off to a webservice and then drop some pins. It currently does this.

On my nav controller, i want it to grab the users current location, go off to the same webservice and return a list of items. It currently does this.

I've not decided how to do the search tab yet - thats another day :).

Currently, i have a location manager for each tab, and each tab set as its own (self) location manager and NSURLConnection (for the web service) delegate.

I have created a singleton delegate class but not used it yet, because i want different things to happen when a location update is received based on the currently selected tab - i.e. drop pins for the map, and reload the tableview for tab 2.

Is there a way to determine what tab sent the message to didUpdateToLocation and connectionDidFinishLoading? In didUpdateToLocation i create the NSURLConnection, and in connectionDidFinishLoading, i parse the JSON from the webservice.

About calling reloadData, i currently have [self.tableView reloadData]; at the end of the connectionDidFinishLoading method, but if i put that in my delegate class, self.tableView obviously wont work... is there a way round this? Is it ok to have multiple location managers and delegates for each tab (good/bad practise)?

Thanks.