Instance Method

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 * _Nullable *)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 YES, 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

- decodeTopLevelObjectOfClass:forKey:error:

Decode an object as an expected type, failing if the archived type does not match.

- decodeTopLevelObjectAndReturnError:

Decodes a previously-encoded object, populating an error if decoding fails.

- decodeTopLevelObjectForKey:error:

Decodes the previously-encoded object associated by a key, populating an error if decoding fails.