appdelegate共享实例委托 [英] appdelegate shared instance delegate
本文介绍了appdelegate共享实例委托的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MyAppDelegate *appD;
appD = [UIApplication sharedApplication];
if(appD.sw1.on)
NSLog(@"It is ON");
else
NSLog(@"It is OFF");
编译时没有错误.在没有任何警告的情况下运行,但是不起作用.
Gives no error while compiling. Runs without any warning, but it doesn't work.
我看不出是什么问题.
...
OMG,也应该调用了委托方法:
OMG, should have called delegate method too:
appD = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
推荐答案
I recommend you this method to share the app delegate: https://coderwall.com/p/z4h4uw?i=2&p=1&q=&t%5B%5D=%21%21mine&t%5B%5D=%21%21bookmarks
这篇关于appdelegate共享实例委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文