简体   繁体   中英

passing array from one view to another

我是一名新的iphone程序员,我想创建一个数组,当我从一个视图移动到另一个视图时,它会在最后一个位置不断添加一个值,因为在最后一个视图中,我需要具有所有视图所有值的完整数组。我试图将一个数组并将其视图发送到下一个视图(在所有视图中都定义了数组),但是当我尝试为其赋值时

最好的方法是在appdelegate中初始化您的mutablearray,并在您要使用的每个类中使用委托的对象使用它。您可以使用addobject添加对象,并可以在任何地方使用propertyObjectAtIndex访问。

You can use NSMutableArray class with addObject: in order to add your views into array. Have a single view controller, declare that array and all your views can access the view controller's array.

尝试将其保存到一个类(singelton类)中,它将起作用。...如果将其转移到委托类中,则一定可以起作用。...在那里建立一个NSMutableArray对象,并在applicationDidFinishLaunching方法中对其进行一次初始化,然后使对象成为对象委托类,并通过addObject方法将您的值传递给它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM