Modifying the prepare(for:sender:) method
When you enter text in the search bar, the journal entries with titles matching the search text will appear in the table view on the Journal List screen. But if you were to tap one of them, the Journal Entry Detail screen may or may not display the details for the tapped journal entry. This is because the prepare(for:sender:) method will reference the journalEntries array in the SharedData.shared instance instead of the filteredTableData array. To fix this, follow these steps:
- Modify the
prepare(for:sender:)method in theJournalListViewControllerclass as shown to assign the appropriateJournalEntryinstance from thefilteredTableDataarray to thejournalEntryproperty for the destination view controller when the search bar is active://MARK: - Navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { super.prepare(for: segue, sender: sender) guard segue.identifier == "entryDetail" else...