Encoding and Decoding
The Cocoa frameworks provide a convention for initializing an object instance by decoding data that has previously been encoded. Encoding and decoding object-instance data is the basis for storing objects on disk, and copying objects to different address spaces. Each class is responsible for encoding and decoding its own state by implementing two methods, -encodeWithCoder: and -initWithCoder:, which are declared in the NSCoding protocol. These methods are automatically called, under certain circumstances, by Cocoa framework classes such as NSCoder, NSArchiver, and NSUnarchiver. Almost all classes in the Cocoa frameworks conform to the NSCoding protocol and implement the two coding methods.
A file or block of memory that ...
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