A protocol that enables encoding and decoding in a manner that is robust against object substitution attacks.
- iOS 6.0+
- macOS 10.8+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Historically, many classes decoded instances of themselves like this:
This technique is potentially unsafe because by the time you can verify the class type, the object has already been constructed, and if this is part of a collection class, potentially inserted into an object graph.
In order to conform to
An object that does not override
init(coder:)can conform to
NSSecurewithout any changes (assuming that it is a subclass of another class that conforms).
In addition, the class must override the getter for its
supportsproperty to return