Overridden by subclasses to substitute another object for itself during encoding.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
func replacementObject(for coder: NSCoder) -> Any?
Parameters
aCoder
The coder encoding the receiver.
Return Value
The object encode instead of the receiver (if different).
Discussion
An object might encode itself into an archive, but encode a proxy for itself if it’s being encoded for distribution. This method is invoked by NSCoder
. NSObject
’s implementation returns self
.