Appearing and Disappearing Views
Whenever a UINavigationController is about to swap views, it calls two methods: viewWillDisappear(_:) and viewWillAppear(_:). The UIViewController that is about to be popped off the stack has viewWillDisappear(_:) called on it. The UIViewController that will then be on top of the stack has viewWillAppear(_:) called on it.
To hold on to changes in the data, when a DetailViewController is popped off the stack you will set the properties of its item to the contents of the text fields. When implementing these methods for views appearing and disappearing, it is important to call the superclass’s implementation – it might have some work to do and needs to be given the chance to do it.
In DetailViewController.swift ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access