I need some info about how to assign, retain objects.
For example - if we have two viewcontrollers and needed to pass an array data from viewcontrlr 1 to viewContrl 2, how can we send the object from view 1 to view 2 and release it in view 1 and retain it in view 2.
A simple = operator is just assigning the address which again points to view 1 object. What is the best way so we can release obj in view 1 and retain a new object in view 2 when passed from view 1.
Create a NSMutableArray in your view controller 2 and declare a retain property for it.
Then in your view controller one you can pass it with:
And it's safe to release it with:
[EDIT TO ADDRESS YOUR COMMENT]
When you declare a retain property for your mutableArrayInVC2 and pass mutableArrayInVC1 to it, "behind the scenes" you are accessing the variable via its setter method as per below:
Hope it makes sense! Rog