Decode an object as an expected type, failing if the archived type does not match.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The expected class of the object being decoded.
The archive key indicating the member to decode.
On return, an
NSErrorindicating why decoding failed, or
nilif no error occurred.
The decoded object, or
nil if decoding fails.
The class indicated by
clsdoes not implement
The unarchived class does not match
cls, nor do any of its superclasses.
If the coder does not require secure coding, it ignores the
cls parameter and does not check the decoded object.