viewwillappear swift code example
Example: view will appear
override func viewWillAppear(_ animated: Bool) {
if let context = (UIApplication.shared.delegate as? AppDelegate)?.persistentContainer.viewContext {
if let coreDataToDoItems = try? context.fetch(ToDoItem.fetchRequest()) as? [ToDoItem] {
toDo = coreDataToDoItems
tableView.reloadData()
}
}
}