I can see the following behaviour when I edit item details and it does not matter whether it is the name, serial or value. When I change the string value and navigate back to the ItemsViewController, the changed string appears unchanged but if I go back to any item details and then back, only then I see the string changed. Tracing itemStore.allItems I can see the changed string is written to the array the same time it appears changed in the ItemsViewController’s view.
Here is my func viewDidDisappear in DetailViewController:
override func viewDidDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Clear first responder
view.endEditing(true)
// "Save" changes to item
item.name = nameField.text ?? ""
item.serialNumber = serialNumberField.text
if let valueText = valueField.text, let value = numberFormatter.number(from: valueText) {
item.valueInDollars = value.intValue
} else {
item.valueInDollars = 0
}
}
Any suggestions what am I doing wrong or missing?