从Objective-C iOS中的视图控制器在应用程序委托数组中添加对象 [英] Adding objects in array of app delegate from view controller in Objective-C iOS

查看:63
本文介绍了从Objective-C iOS中的视图控制器在应用程序委托数组中添加对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助我在Objective-C中从UIViewController的应用程序委托数组中添加对象我想我做错了,在这方面帮助我

Help me in adding objects in array of app delegate from UIViewController in Objective-C I guess I am doing mistake, help me in this regard

我想从视图控制器的应用程序委托数组中添加对象

I want to add objects in array of app delegate from view controller

在 appdelegate.h 中

in appdelegate.h

@property (nonatomic, retain) NSMutableArray *sharedArray;

在 appdelegate.m 中

in appdelegate.m

@implementation AppDelegate
@synthesize sharedArray;

里面didfinishlaunching

self.sharedArray = [[NSMutableArray alloc] init];

在视图控制器中

@interface ViewController () {

    UIApplication *appDelegate;


viewcontroller

appDelegate = [[UIApplication sharedApplication] delegate];
[appdelegate.sharedArray addObject:array];

推荐答案

更改声明

UIApplication *appDelegate;

AppDelegate *appDelegate;

//

self.appDelegate =  (AppDelegate *)[[UIApplication sharedApplication] delegate];

//在上面你应该

#import "AppDelegate.h"

这篇关于从Objective-C iOS中的视图控制器在应用程序委托数组中添加对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆