NSCoding
NSSecureCoding
Technology
Use these APIs to convert your app’s in-memory types to representations suitable for serialization over I/O and network interfaces or to long-term storage.
In Swift, the standard library defines the Encodable
, Decodable
, and Codable
types, along with Encoder
and Decoder
APIs to perform encoding and decoding, as described in Encoding, Decoding, and Serialization. Foundation extends this with the Encodable
and Decodable
protocols, used for types that require additional static information to encode and decode, such as Attributed
.
In Objective-C, NSCoding
defines a protocol for encoding and decoding objects. When adding serialization to your own types, you should also adopt NSSecure
. This protocol adds protection against security vulnerabilities introduced by instantiating arbitrary objects as part of the decoding process.
Many system frameworks use these types. When working with external systems, such as URL endpoints, use the JSON and XML APIs to serialize your app’s types to standard formats.
NSCoding
NSSecureCoding
NSJSONSerialization
NSPropertyListSerialization
NSKeyedArchiver
NSKeyedArchiverDelegate
NSKeyedUnarchiver
NSKeyedUnarchiverDelegate
NSCoder
NSSecureUnarchiveFromDataTransformer
NSArchiver