Type Method

archivedDataWithRootObject:requiringSecureCoding:error:

Encodes an object graph with the given root object into a data representation, optionally requiring secure coding.

Declaration

+ (NSData *)archivedDataWithRootObject:(id)object requiringSecureCoding:(BOOL)requiresSecureCoding error:(NSError * _Nullable *)error;

Parameters

object

The root of the object graph to archive.

requiresSecureCoding

A Boolean value indicating whether all encoded objects must conform to NSSecureCoding.

error

On return, the error that occurred while encoding, or nil if no error occurred.

Discussion

To prevent the possibility of encoding an object that NSKeyedUnarchiver can’t decode, set requiresSecureCoding to true whenever possible. This ensures that all encoded objects conform to NSSecureCoding.

See Also

Archiving Data

- finishEncoding

Instructs the receiver to construct the final data stream.

encodedData

The encoded data for the archiver.

outputFormat

The format in which the receiver encodes its data.

requiresSecureCoding

Indicates whether the archiver requires all archived classes to resist object substitution attacks.

+ archivedDataWithRootObject:

Returns a data object that contains the encoded form of the object graph formed by the given root object.

Deprecated
+ archiveRootObject:toFile:

Archives an object graph rooted at a given object to a file at a given path.

Deprecated