如何创建可以从不同视图控制器访问的NSMutable Array [英] How to create a NSMutable Array which can access from different view controllers

查看:131
本文介绍了如何创建可以从不同视图控制器访问的NSMutable Array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone开发的新手,我想创建一个可变阵列,可以从不同的视图控制器访问和填充
我该怎么办?
如果可以,请给我一个示例代码

Im quite new to iphone development, I want to create a mutable array which can access and populate from different view controllers. How can I do it? If you can please give me a sample code

推荐答案

在大多数情况下,使用全局变量不需要也没有帮助。
如果必须使用它们,最简单的方法是将数组放入AppDelegate。

In most cases its not needed nor helpfull to use global variables. If you have to use them the easiest way is to put the array in your AppDelegate.

您可以访问数组(此处为AppDelegate中的命名数组) :

You can access the Array (named array in AppDelegate here) with :

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];

NSArray *aArray= [appDelegate array];

这篇关于如何创建可以从不同视图控制器访问的NSMutable Array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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