tags:

views:

22

answers:

1

Created a new project from the Tab Bar Application template, how can I access tabBarController (which is declared in AppDelegate) from FirstViewController? I'd like to read some attributes in the tabBarController from the view controller. Thanks!

A: 

You can always access the app delegate as follows:

[UIApplication sharedApplication].delegate

So you should be able to get at the tabBarController by doing this:

MyAppDelegate *delegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;

Now refer to delegate.tabBarController.

[In the above, MyAppDelegate is whatever name you gave the class of your app delegate.]

William Jockusch