【发布时间】:2018-04-11 10:54:15
【问题描述】:
帮助我在 Objective-C 中 UIViewController 的应用程序委托数组中添加对象我想我做错了,在这方面帮助我
我想在视图控制器的应用委托数组中添加对象
在 appdelegate.h 中
@property (nonatomic, retain) NSMutableArray *sharedArray;
在 appdelegate.m 中
@implementation AppDelegate
@synthesize sharedArray;
在didfinishlaunching内
self.sharedArray = [[NSMutableArray alloc] init];
在视图控制器中
@interface ViewController () {
UIApplication *appDelegate;
viewdidload 内部 viewcontroller
appDelegate = [[UIApplication sharedApplication] delegate];
[appdelegate.sharedArray addObject:array];
【问题讨论】:
-
你能解释一下你想做什么吗?
-
您的问题是什么?反正你不需要在
ViewController中声明appDelegate -
我想在视图控制器的应用委托数组中添加对象
-
@iOSDeveloper 查看 Anbu 的回答。
-
在你想使用的地方导入 AppDelegate
标签: ios objective-c nsarray