Archives and Serialization

Convert objects and values to and from property list, JSON, and other flat binary representations.

Topics

First Steps

NSCoding

A protocol that enables an object to be encoded and decoded for archiving and distribution.

NSSecureCoding

A protocol that enables encoding and decoding in a manner that is robust against object substitution attacks.

JSON

Using JSON with Custom Types

Demonstrates approaches for encoding and decoding different kinds of JSON in Swift.

NSJSONSerialization

An object that converts between JSON and the equivalent Foundation objects.

Property Lists

NSPropertyListSerialization

An object that converts between a property list and one of several serialized representations.

Keyed Archivers

NSKeyedArchiver

A coder that stores an object's data to an archive referenced by keys.

NSKeyedArchiverDelegate

The optional methods implemented by the delegate of a keyed archiver.

NSKeyedUnarchiver

A decoder that restores data from an archive referenced by keys.

NSKeyedUnarchiverDelegate

The optional methods implemented by the delegate of a keyed unarchiver.

NSCoder

An abstract class that serves as the basis for objects that enable archiving and distribution of other objects.

Deprecated

NSArchiver

A coder that stores an object's data to an archive.

Deprecated
NSUnarchiver

A decoder that restores data from an archive.

Deprecated
NXReadNSObjectFromCoder

Returns the next object from the coder.

Deprecated

See Also

Files and Data Persistence

File System

Create, read, write, and examine files and folders in the file system.

Preferences

Persistently store domain-scoped pieces of information used to configure your app.

Spotlight

Search for files and other items on the local device, and index your app's content for searching.

iCloud

Manage files and key-value data that are automatically synchronized among a user's iCloud devices.