I have a problem changing the value of a Dictionary in a Array
var array = (defaults.array(forKey: "Transactions")! as! [Dictionary<String, Any>])
(array.reversed()[index]["Title"] as! String) = titleTextField.text! // Cannot assign to immutable expression of type 'String'
Cannot assign to immutable expression of type ‘String’
This is the error I get back
Is there a solution to this problem?
2
Answers
As Joakim points out, array.reversed() returns an immutable array.
Try this:
(And then re-save your array to UserDefaults)
One more step will work