开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜