Generic Type Method

unarchivedObject(ofClass:from:)

Decodes a previously-archived object graph, and returns the root object as the specified type.

Declaration

@nonobjc static func unarchivedObject<DecodedObjectType>(ofClass cls: DecodedObjectType.Type, from data: Data) throws -> DecodedObjectType? where DecodedObjectType : NSObject, DecodedObjectType : NSCoding

Parameters

cls

The expected class of the root object.

data

An object graph previously encoded by NSKeyedArchiver.

Return Value

The decoded root of the object graph, or nil if an error occurred.

Discussion

This method produces an error if data does not contain valid keyed data.

See Also

Unarchiving Data

class func unarchiveTopLevelObjectWithData(Data) -> Any?

Decodes a previously-archived object graph, and returns the root object.

static func unarchivedObject(ofClasses: [AnyClass], from: Data) -> Any?

Decodes a previously-archived object graph, returning the root object as one of the specified classes.

var requiresSecureCoding: Bool

Indicates whether the receiver requires all unarchived classes to conform to NSSecureCoding.

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

Decodes and returns the object graph previously encoded by NSKeyedArchiver and stored in a given NSData object.

Deprecated
class func unarchiveObject(withFile: String) -> Any?

Decodes and returns the object graph previously encoded by NSKeyedArchiver written to the file at a given path.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software