Quote:
Originally Posted by RLScott
You should do this in two steps. When the button in the first view is pressed, change the model data that represents the information in the second view. Then call setNeedsDisplay for the second view. That will cause the model data to be used to repaint the second view. This is more robust than storing data in the view itself because views are often released when they are hidden and need to be regenerated when they reappear.
|
Adding to what RL said.
I would take it a step further. It's really best if one view controller doesn't modify the views of another view controller directly. If you do that, and later change the views in your view controller in the future, you have to find every outside object that uses the views and change them too.
What I would do is add a method called something like newMessage to your view controller. Have that method save the new value to an instance variable and then change the label. Also have your viewDidLoad method set the label using the instance variable. That way, if the views get unloaded because of low memory, the label will be restored to the correct value the next time the view controller displays it's views.
So:
View controller 1 calls [viewController2 newMessage: @"some message"];
View controller 2 saves the new message and then displays it to a label.