views:

198

answers:

2

Hi guys,

I am still trying to develop a small medicine iPhone app. :-] In the last few days I've structured all the data that should be displayed in a table. After reading books and watching a lot of tutorials I've built a couple of simple Table View applications. These apps always had a predefined depth of data. I am not sure if you understand what I mean by that, so please open the following links to compare my graphics:

You can find the graphics here!

File hierarchie1.png shows the normal data hierarchy I already used in my apps. My data is structered like in the file hierarchie2.png.

Unfortunately I am not very experienced with iPhone development. My idea is to create for every section of the tree an own view controller.

  • EintragAViewController manages 1 - 2 - 3
  • Eintrag1ViewController manages 1.1
  • Eintrag11ViewController manages 1.1.1 - 1.1.2 and so on...

I hope you can get what I mean.

What I would like to know is if my idea is the right approach to realize that kind of data? Or is there another and better way to do it?

Thank you!

+1  A: 

Check out UINavigationController and the sample "Navigation-based application" that Xcode offers as a template project.

Essentially, each child node type ("Eintrag" type) in your application will be a UIViewController subclass.

References to view controllers are placed on the UINavigationController stack. You push and pop references to navigate through the view hierarchy.

In each view controller, to open another child node, you call the -pushViewController:animated method on the navigation controller, e.g.:

[self.navigationController pushViewController:eintragType1Instance animated:YES];

You'll usually have a "back button" in the top-left corner of the application window. This triggers a "pop", programmatically equivalent to:

[self.navigationController popViewControllerAnimated:YES];
Alex Reynolds
A: 

Your thought makes sense if for each kind of tree, the nodes at any level are all of the same type - so table cells in EintragA, section 1 are the same kinds of cells used in EintragA, section 2.

As you push to deeper levels, you can make new instances of the same types of view controllers and just tell them what level of data to display.

Kendall Helmstetter Gelner