views:

372

answers:

1

Hi, Im working off the seismic xml iphone example. In that example there is simply the application delegate which has a rootViewController of type UITableViewController.

I wanted to modify it slightly so that I would have a navigationController and use its rootViewController as the table view. My root view controller class for my navigation controller is named "firstLevelViewController"

In the sample code it says

 [rootViewController.tableView reloadData];

I want to say [navController.firstLevelViewController.tableView reloadData]

but I get errors saying "request for member firstLevelViewController in something is not a structure or union"

How can I reference the rootViewController of the navigationcontroller from the main app delegate?

+1  A: 

There isn't a firstLevelViewController property in a UINavigationController. If you want to access the current controller you can use

UITableViewController* firstLevelViewController = navController.topViewController;
assert([firstLevelViewController isKindOfClass:[UITableViewController class]]);
[firstLevelViewController.tableView reloadData];

If firstLevelViewController means the view controller at the bottom you can use

UITableViewController* firstLevelViewController = [navController.viewControllers objectAtIndex:0];
....
KennyTM
AH! Thankyou so much.What I meant by "firstLevelViewController" was the default 1st root screen that the navigation control shows.I read in a book that this always exists.If I always want to refer to that firstLevelViewController that I'm on about would I use the objectAtIndex:0 method?
dubbeat
@dubbeat: Yes. But it may be more efficient to store the value in some properties of your App delegate or a static global variable.
KennyTM