且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数组从一个视图添加到另一个视图并保留值

更新时间:2023-02-01 16:07:08

有两种方法可以对其进行初始化:我可以想一想。首先,您可以在应用程序委托中分配/初始化数组。

There are two ways you could go about initializing it that I can think of offhand. First, you could alloc/init the array in the app delegate. This will ensure it's created before the rest of the views get a chance to add to it.

编辑:乔什·卡斯威尔(Josh Caswell)是我想到的唯一一种方法指出了一个很好的事实,类初始化不适用于这种情况。***不要在应用程序委托中调用数组的alloc / init,或者先将哪个视图设为键窗口。您必须从那里参考其他课程

There's only really one way I can think to do this as Josh Caswell pointed out a good fact that class initializations won't work for this situation. You're best off calling alloc/init for the array either in the app delegate or whichever view is made key window first. You'll have to reference it to the other classes from there