Contents

unarchiveObject(with:)

Decodes and returns the object archived in a given NSData object.

Declaration

class func unarchiveObject(with data: Data) -> Any?

Parameters

  • data:

    An NSData object that contains an archive created using NSArchiver.

Return Value

The object, or object graph, that was archived in data. Returns nil if data cannot be unarchived.

Discussion

This method invokes init(forReadingWith:) and decodeObject() to create a temporary NSUnarchiver object that decodes the object. If the archived object is the root of a graph of objects, the entire graph is unarchived.

See Also

Related Documentation

Decoding objects