I’ve Created a UITableViewController subclass. Do I only need one controller? Do I just instantiate multiple instances of that one subclass?
The iPhone App I’m building will start with a Table of a list of people. If the user taps a person, a new table will be pushed in with a list of Companies they’ve worked for. If the user then taps a company, they’ll see a list of Job Positions. And if they tap a position they’ll see a list of people holding those positions.
This could go on forever, and the user could always back up the list.
The App Delegate instantiates the Navigation Controller and the Table View Controller and then pushes it onto the Navigation Controller. But when a user taps a row, now the TVC is creating another TVC.
-
Is that right or should the
AppDelegate be instantiating all
TVC’s? Or does it work out since
they all get pushed onto the Nav
Controller anyway? -
Does each Table View instance
need to have a different name or can
they all be called ‘mainTVC’ or
something like that?tableViewController *mainTVC = [[tableViewController alloc] init]; -
Won’t I run out of memory? Do i
need to start dropping Table Views
when they’re 2 or 3 levels away from
current, and then re-create it if
the user backs up to it?
I’d create a view controller for each type. Presumably you’ll want to have special display characteristics like a custom tableview cell to display job positions slightly differently then you would people names.
Other then that, @Ben Gottlieb’s answer should work quite well. Use lots of view controllers and handle the
didReceiveMemoryWarning:method.One more thing, if the user drills down so far that you want to say they’ll never go all the way back (sort of like having an undo stack) you can use the
setViewControllers:animated:UINavigationControllermethod to reset the stack to a certain size (say 15 to implement an ‘undo buffer’ of 15). With this method you can make sure that the first view controller is always your root view controller and the rest are all drilldown instances.