views:

14

answers:

1

Situation:
I am using the "Navigation Based Application" project template. And my root view controller (UIViewController) needs to call a method of the app delegate.

Question:
How do I call a method of the app delegate from a UIViewController?

+1  A: 
[[[UIApplication sharedApplication] delegate] someMethod];

Or in applicationDidFinishLaunching: set a static member that is returned by a static method of your delegate class.

+(id) shared { return sAppDelegate; }
-(void) applicationDidFinishLaunching:(UIApplication *)a { sAppDelegate = self; }

Or just use a global without the wrapper.

drawnonward