I have some problems regarding archiving and unarchiving data in swift 3.0.
I read some posts about the same but still don't have complete clarity about some cases.
enum
(I usedrawValue
to archive it.)struct
(I read about theextension
method to archive it in http://swiftandpainless.com/nscoding-and-swift-structs/). Is there any other way to do it?Array
Since array
is also a struct
, so it must also follow the archiving convention same as of a struct
. But I am able to archive an array
of basic data types eg. String, Int
etc. directly. i.e.
let arr = ["1", "2"]
, is archived directly without any extension
.
Also, how does it work in an array of custom objects
?
Set
Dictionary
I had the same issue and found this solution for my struct:
}
I can call the archiver like this:
and the unarchiver like this:
But when I enter a name with a space the app crashes. I don't no why, because in case of season and episode there are also spaces like in "Season 1".