Archives and Serialization アーカイブとシリアライゼーション

Convert objects and values to and from property list, JSON, and other flat binary representations. オブジェクトと値をプロパティリスト、JSON、そして平坦なバイナリ表現へとおよびそれから変換します。

Overview 概要

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 EncodableWithConfiguration and DecodableWithConfiguration protocols, used for types that require additional static information to encode and decode, such as AttributedString.

In Objective-C, NSCoding defines a protocol for encoding and decoding objects. When adding serialization to your own types, you should also adopt NSSecureCoding. 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.

Topics 話題

Adopting Codability

Serializing Arbitrary Payloads 恣意的なペイロードをシリアル化する

JSON

Property Lists プロパティ・リスト

XML

Keyed Archivers キー付きアーカイバ

Deprecated 非推奨

See Also 参照

Files and Data Persistence ファイルとデータ永続