archivedData(withRootObject:requiringSecureCoding:)
Encodes an object graph with the given root object into a data representation, optionally requiring secure coding.
Declaration
class func archivedData(withRootObject object: Any, requiringSecureCoding requiresSecureCoding: Bool) throws -> DataParameters
- object:
The root of the object graph to archive.
- requiresSecureCoding:
A Boolean value indicating whether all encoded objects must conform to Nssecurecoding.
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.