I have a struct called trip
:
struct trip {
var name: String
var description: String
var elements: [elementType] = []
}
elementType
is a type declared in protocol.
Then I've declared an array called trips
:
var trips: [trip] = []
The problem is that I have to save trips
array to be able to show items after closing the app. First of all, I tried to use NSUserDefaults but it can save only few types and Any
(type of struct) isn't one of them.
How can I save and restore this array?