Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 10, 2011, 10:56 AM   #1
RonC
macrumors regular
 
Join Date: Oct 2007
Location: Chicago-area
Nested TableViewControllers

Maybe I missed something when I learned about TableViewControllers. I'm struggling with a simple concept - nested TableViewControllers - and I'm looking for the right design pattern / idiom for this.

When I say nested, I mean a hierarchy of tables - as an example, consider this:
a first table view is presented with 3 options: A, B, and C. If A is selected, another table view is presented with options a,b, and c; if B is selected, a different table view is presented with options x, y, and z; and if C is selected, yet another table view is prestned with options 1, 2, and 3. This continues through the hierarchy of possible options.
I've coded this up with a whole set of TableViewControllers that get pushed onto the navigation stack (FirstTableViewController, AnotherTableViewController, DifferentTableViewController, and YetAnotherTableViewController) as the various options are selected, but it seems both tedious and sub-optimal. Tedium and sub-optimal are fine when it's limited, but I'm afraid it won't stay that way (and further I expect other apps will follow this same pattern).

I did a quick search through this forum and didn't find anything that seemed to match, so I'm asking. Is there a better design pattern for this or is this the right way to do it?
RonC is offline   0 Reply With Quote
Old May 10, 2011, 11:01 AM   #2
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
I defined my own protocol that defines how the table is populated with data, and push instances of the same table view controller with different data source objects.
robbieduncan is offline   0 Reply With Quote
Old May 10, 2011, 11:28 AM   #3
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
This is sometimes called a drill-down interface.

Obviously UITableViewController does most of the work. It's designed to be data-driven. That is it is very flexible and it displays whatever rows are presented to it.

If you have a drilldown interface it's not that hard to come up with a data model that is hierarchical so that you can display a part of it in the tableview. It also has to be able to contain the information of what is the next set of data to be displayed. So if the user taps row 5 of the second of A, B, C dataset it has to be able to determine from the data what needs to be pushed. If you can design that then you can use one view controller class. You need a single data model that holds all the info.

If you have something to display like Countries, States, Cities the view controller needs to be able to know where it is in that hierarchy so it can pass it to a new instance of the view controller at the next level of the drilldown.
PhoneyDeveloper is offline   0 Reply With Quote
Old May 10, 2011, 05:10 PM   #4
RonC
Thread Starter
macrumors regular
 
Join Date: Oct 2007
Location: Chicago-area
Thanks, that's very helpful. I've seen drill down before, it just never clicked that it could be as simple as that.

Sometimes I feel like I'm just a shill for the house...
RonC is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Question on creating TableView without TableViewController (doesn't display!) tutiplain iPhone/iPad Programming 10 Mar 3, 2011 03:53 PM
Crash in TableViewController gameplayerxp iPhone/iPad Programming 6 Dec 3, 2010 01:39 AM
problem calling a TableViewController (Iphon-SDK) subhransu.beher iPhone 0 Apr 1, 2009 01:10 PM
show/hide support... mutiple nested divs... mnkeybsness Web Design and Development (archive) 0 Feb 5, 2004 07:08 PM


All times are GMT -5. The time now is 06:16 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC