unarchiveObject(with:)
Decodes and returns the object archived in a given NSData object.
Declaration
class func unarchiveObject(with data: Data) -> Any?Parameters
- data:
An
NSDataobject that contains an archive created usingNSArchiver.
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.