在另一个类中的应用程序委托中使用NSMutableArray [英] Use NSMutableArray in app delegate in another class
本文介绍了在另一个类中的应用程序委托中使用NSMutableArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程式委托中有一个 NSMutableArray
。我希望在我的程序中的不同类中使用该可变数组,就好像它是一个全局变量。
I have an NSMutableArray
in my app delegate. I wish to use that mutable array in a different class in my program, as if it were a global variable. How would I do this?
推荐答案
解决方案
利用UIApplication单例:
Take advantage of the UIApplication singleton:
YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
然后,访问您的数组属性如下: appDelegate.yourArrayProperty
Then, access your array property like this: appDelegate.yourArrayProperty
这篇关于在另一个类中的应用程序委托中使用NSMutableArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文