How NSCoding and NSKeyedArchiver/Unarchiver Work Together to Encode/Decode Objects

Mark van Wijnen
3 min readAug 15, 2022
Photo by Erda Estremera on Unsplash

The NSCoding protocol declares how an instance of a class can be encoded or decoded. This capability is then used byNSKeyedArchiver (a NSCoder) to encode the instance into an architecture-independent format suitable for archiving to disk or for distribution over the network. After that NSKeyedUnarchiver is used to decode the data back to the original…

--

--

Mark van Wijnen

macOS/iPadOS/iOS/watchOS/visionOS developer and SwiftUI enthousiast. “Stay Hungry, Stay Foolish!” — Steve Jobs