I am using NSCoding and NSArchiver to persist my iOS App Data. But I want to know if it is equivalent to using zip / unzip software? If not, how does it work?
-
No, it's not at all similar. – rmaddy Jul 29 '18 at 03:21
2 Answers
You can read the docs to get a rough idea of how NSArchiver
works:
[...] provides a way to encode objects into an architecture-independent format that can be stored in a file
Basically, it converts an object in memory (and all the other objects that it references, and the objects that those objects references... i.e. "object graph") into a file that can be stored in a file.
This is not the same as compression. NSArchiver
simply encodes your objects into some format (binary, XML etc.). Compression would be to make that encoded binary file smaller.
See this post for how to compress files.

- 213,210
- 22
- 193
- 313
In effect, it is a property list. That is why NSKeyedArchiver has an outputFormat
property that can be an XML property list or a binary property list.
See the documentation on the PropertyListSerialization class for more about what that means.
You can actually write an archive to disk, open it as XML, and read it.

- 515,959
- 87
- 875
- 1,141