I want to use structs for the (very simple) model of my app.
However NSKeyedArchiver
only accepts objects (extending NSObjects
).
Is there any good way to save a struct to a file?
I want to use structs for the (very simple) model of my app.
However NSKeyedArchiver
only accepts objects (extending NSObjects
).
Is there any good way to save a struct to a file?
A very simple approach I used sometimes. The quantity of code you need to write is no more then in the class/NSCoding scenario.
First of all import the great SwiftyJSON lib.
Let's start with a simple struct
Let's make it convertible to/from a JSON
That's it. Let's use it