You may notice that the to-do item you put in is gone when you restart the app. Such an app is useless for the user. The app needs to store the to-do items somehow and reload them when it is opened the next time. There are different possibilities to implement this. We could use Core Data, serialize the data using
NSCoding, or use a third-party framework. In this book, we will write the date into a property list (plist). A plist has the advantage that it can be opened and altered with Xcode or any other editor.
The data model we have implemented uses structs. Unfortunately, structs cannot be written to a plist. We have to convert the data into
Any arrays and
String:Any dictionaries. Add the following code to