开发者

Transferring data in an array from view to view

I have a class, call it Class1, which contains an array, call it array1, as a property, and I retain and synthesize it.

I want to add objects to that array with values I get from other views. So for each view, I reference Class1, create an object, and I add the value to array1 and display it for that particular view. This works!

When I go to the new view, I am required to reinitialize array1 to copy the new objects to it (or it gives me an error that array1 is null), but the prev开发者_StackOverflow社区ious value (the value which was stored in the previous views) is lost. I understand that "retain" is for a specific class, and the array does not retain values for the whole course of the program.

How do I go about this?


You can consider creating a singleton class which you can access anywhere in your application. Apple docs have a standard approach for creating singleton classes. You can make Class1 a singleton class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜