从Tab Bar Application
模板创建了一个新项目,如何从tabBarController
访问AppDelegate
(在FirstViewController
中声明)?我想从视图控制器中读取tabBarController
中的一些属性。谢谢!
答案 0 :(得分:2)
您始终可以按如下方式访问应用代理:
[UIApplication sharedApplication].delegate
所以你应该能够通过这样做来获得tabBarController:
MyAppDelegate *delegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
现在请参阅delegate.tabBarController。
[在上文中,MyAppDelegate是您为应用代表的类提供的任何名称。]