Contents

decodeTopLevelObjectOfClasses:forKey:error:

Decode an object as one of several expected types, failing if the archived type does not match.

Declaration

- (id) decodeTopLevelObjectOfClasses:(NSSet<Class> *) classes forKey:(NSString *) key error:(NSError **) error;

Parameters

  • classes:

    A set of expected classes that the object being decoded should match at least one of.

  • key:

    The archive key indicating the member to decode.

  • error:

    On return, an Nserror indicating why decoding failed, or nil if no error occurred.

Return Value

The decoded object, or nil if decoding fails.

Discussion

This method is equivalent to decodeObject(of:forKey:), but allows you to specify a set of classes that the decoded object can match. If requiresSecureCoding is true, the decoded object’s class must be a member of the classes parameter, or a sublcass of a member.

See Also

Decoding Top-Level Objects