Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This question is super broad and there are multiple parts to making this work. If you break it down into discreet steps, then you can probably find the sample code for each step on SO already, or ask a more specific question. If you want help for any individual step, post a comment and I can guide you, but there is too much here to type out in a single question. </p> <p>Here's how I think you need to tackle this project:</p> <p>Step 1. Create your data structure</p> <p>You're going to want to use an NSArray for each level. The NSArray can store a list of NSDictionaries or your own custom NSObject class. Both will work. If there is a standardized data structure then I would recommend creating your own object that you then store for each entry in the array. It makes it easier to access properties of the object than having to do a dictionary lookup for every access. Of course the object you store in the array, will need a field for another NSArray which would be the child array below it. So for example you may have something like this:</p> <pre><code>@interface MyObject : NSObject { NSString *nodeTitle; NSString *nodeDescription; NSArray *childArray; } @property (nonatomic, copy) NSString *nodeTitle; @property (nonatomic, copy) NSString *nodeDescription; @property (nonatomic, copy) NSArray *childArray; </code></pre> <p>In the .m file of your class you will then want to set each ivar to nil on init and release each ivar on dealloc.</p> <p>Step 2. Load your data</p> <p>Does your feed come down all in one big batch, or can you request it one level at a time from the server? Ideally you are not storing 300 levels deep into memory if you can avoid it (that sounds like a pretty big xml file). Ideally you are loading each level as the user steps down into the hierarchy. But perhaps there is minimal amount of data at each node and you can load it all in one step and not hog a ton of memory. You need to figure out the load routines (one shot, or on demand).</p> <p>Step 3. Present your data</p> <p>This is actually pretty simple. Create a view controller that uses a table view (either a UITableViewController or UIViewController with a UITableView imbedded). Create an ivar of type NSArray and a property on your view controller for this ivar (copy it). Then when you create this view controller, pass it the NSArray for the current level before you push it onto the navigation stack. Then setup the table view to present the NSArray ivar that is passed as a property to the view controller. So for example when someone click a row in the table that loads a child level, do this:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; int row = [indexPath row]; MyViewController *childView = [[MyViewController alloc] init]; childView.contentArray = ((MyObject *)[contentArray objectAtIndex:row]).childArray; [self.navigationController pushViewController:childView animated:YES]; [childView release]; } </code></pre> <p>This assumes you've created your standard object called MyObject for each entry in the array and it has a property called childArray which is the array for the next level down.</p> <p>That'll do it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload