I have a mutable array of values used in a tableviewcontroller, a mapviewcontroller, and the callingviewcontroller. I have been updating them all, ie.
[dataArray addObject:object atIndex:0];
[tvc. dataArray addObject:object atIndex:0];
[mvc. dataArray addObject:object atIndex:0];
Is there a way of declaring dataArray in the table and map viewcontrollers that would make them pointers to the dataArray in the callingViewController? So I would just have to update one?
***Okay guys, I made a really stupid mistake here. At some point I changed the initialization and passed nil as the dataArray, and for some reason I had an “if (!dataArray) create new” clause to hide it from myself.
Kaan is correct.
[dataArray addObject:object atIndex:0];
is all that is needed.
After your comment:
How about you declare a property called
dataArrayin both your tableView and mapView and also callingView. Then, in your callingViewController, you initialize a mutable array called lets say myFirstArray and do:This way they will both be pointing to the same object and change you do in one will reflect in the other. Give it a try!