Archiving
There are many ways to write data to the filesystem on iOS, and one of the most important is called archiving. Archiving is the process of taking one or more objects from memory and writing them to the filesystem. Unarchiving reads these objects back from the filesystem into memory.
Archiving works by creating an instance of NSCoder, which is essentially just a container for data, and placing objects and their data inside it. Once the NSCoder has all of the data you have instructed it to collect, it will be written to a specific file in the filesystem.
Not all objects can be archived – only those whose class conforms to the NSCoding protocol. The NSCoding protocol has two methods, and both are required: encodeWithCoder: (for archiving) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access