iosuitableviewsegueuikit-state-preservation

Modal Segue View Controller Preservation


I have a quick question. I have a ViewController (parent) that has a UITableView in it. Within that view contains a button triggering a modal segue to another viewController (child) with a UITableView. The child viewController acts as a filter to update the parent's table. My goal is to preserve the state of the filter viewController (child) after dismissal, so I can go back and update the filter selection.

After researching, I have found the docs contain information on preserving the state of the application as a whole, in situations where the app closes, etc. I am unsure if this is the sort of approach I need in order to preserve this viewController after dismissal.

Links are here:

Apple Docs

Blog Walkthrough

Is this the proper way of approaching this or do I have it all wrong?

Thanks!


Solution

  • I ended up using delegation to pass the child view controller back to the parent and storing the entire view controller as a variable in the parent. That way, the child view controller's life cycle is as long as the parents. Also, I could reload the existing child view controller when calling for that specific segue.