I created an app with two different calculator views, each one with a separate view controller and separate nib file. I set up a tab bar on the each view to switch back and forth between views. When I switch views each view controller retains whatever data has been input.
I recreated the same app using the storyboard feature. So now I have one nib file only with the same two view controllers. But when I transition between views I lose whatever data has been input on the second view. I am wondering why I now lose the data and how to retain it when leaving the sub view.
Any help appreciated.
I believe this is because the storyboard is being more aggressive about releasing view controllers that are no longer on screen. I expect you would have seen the same behavior with separate nibs in high memory pressure situations.
In short, you as the programmer should design your view controllers expecting them to be released as soon as possible. Work out a plan for simple data persistence to ensure that the user’s data is always available. Don’t count on view controller objects sticking around to ensure that the state is preserved.