I store the data for my app in UserDefaults using JSONEncoder and read it back using JSONDecoder.
Everything works fine until I add another field to the struct that describes the data. When I start the app, the JSONDecoder tries to read the new field, which doesn’t yet exist in the data. The error is ‘keyNotFound’ and it causes the JSONDecoder to abort without returning any data.
Is there a way around this? I would like to read the data that doesn’t have this new field, then, when I save it, the new field will be there. This seems like a fairly common situation.