singhspk
singhspk

Reputation: 2519

How to present hierarchical data using tableviewcontroller in ios

Am a newbie to ios development.

Building a simple app that lets users navigate hierarchical data. For e.g., navigating directory structures.

We built a TreeViewController and set the data source to the first level. What's not clear is to how to initialize the same controller and push it so that the next level can be represented.

I tried the following:

UIStoryboard *storyboard = [self storyboard];
CVBrowseViewController *selfController = [storyboard instantiateViewControllerWithIdentifier:@"browseTable"];


//Push the new table view on the stack
[self.navigationController pushViewController:self animated:YES];

[selfController setFolderList:children];

However, this throws an error: Pushing the same view controller instance more than once is not supported

Upvotes: 1

Views: 267

Answers (1)

foundry
foundry

Reputation: 31745

This line:

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

should be:

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

Upvotes: 3

Related Questions