I\'m working on an iOS5 app using storyboard, and I have a method in a view controller class that i\'d like to access from the App Delegate. The trouble is, this view contr
I probably would do it in reverse. Create a method in AppDelegate call registerViewController or something. In every ViewController, call the method with itself with a name. Then in AppDelegate, you can do whatever you want afterward. It is messy to do all sort of drill
In AppDelegate
- (void)registerViewController:(NSString *)name controller:(UIViewController *)controller
{
if(_viewControllers == nil)
{
_viewControllers = [[NSMutableDictionary alloc] init];
}
[_viewControllers setObject:controller forKey:name];
}
In any ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate registerViewController:@"feelings" controller:self];
}
In AppDelegate
XViewController *vc = (XViewController *)[_viewControllers objectForKey:@"X"];
[X startSpinner];
Hope this help
BS