In Xcode 4.2, I created a new project from the “tabbed application” template. Now I want to access the tab bar controller in the AppDelegate, but this property is missing. How to solve the problem.
In previous version of Xcode, I can access it by calling the self.tabBarController, however, I could not do that in iOS 5.
There’s no magic happening with the
tabBarControllerproperty that appears in “tabbed application” template projects. I guess pre-iOS 5 the template was designed so that the tab controller was already set up as an attached outlet for you. If it’s not in the template you’re using then you just need to add the property yourself. Below are instructions on how to do this.You just need to add a property for it and then grab the
rootViewControllerfrom yourUIWindowinapplicationDidFinishLaunching. i.e. you want something like this in your app delegate header:Then synthesise it in your app delegate implementation and grab it from
rootViewController: