Legolas
Legolas

Reputation: 12325

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 previous 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?

Upvotes: 0

Views: 108

Answers (1)

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

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.

Upvotes: 2

Related Questions