我在 ViewController.h 中有 NSMutableArray 属性现在我想从 appdelegate 获取这个数组值。 有没有人可以帮助我做到这一点。
在viewcontroller.h中
@property (nonatomic, retain) NSMutableArray *fullImg;
在viewcontroller.m中
@synthesis fullImg;
我还为 fullImg 分配了值。现在我想在应用程序委托(delegate)中获取该值。
提前致谢。
最佳答案
- 将数组声明从 viewController 移至 AppDelegate
- 在 viewController.m 中做:
顶级文件: #import "AppDelegate.h"
在你想使用数组的地方:
AppDelegate *ap = [[UIApplication sharedApplication] delegate];
ap.fullImg // -> USE IT HOW YOU WANT
...
关于ios - 如何从 appdelegate 获取 viewcontroller 中 NSMutableArray 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24734933/