How do I call a method of the app delegate from a UIViewController?
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?[[[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.
精彩评论