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.
我不明白这是什么问题.
I dont see what the problem is.
...
OMG,应该也调用了委托方法:
OMG, should have called delegate method too:
appD = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
推荐答案
我推荐你使用这种方法来共享应用程序委托:https://coderwall.com/p/z4h4uw?i=2&p=1&q=&t%5B%5D=%21%21mine&t%5B%5D=%21%21 个书签
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屋!
查看全文