encodeWithCoder
encodeWithCoder is a method in the NSCoding protocol of Apple's Foundation framework. It is called when an object is being archived or serialized by an archiver such as NSKeyedArchiver. The method's purpose is to encode the receiver's property values into the provided coder so the object can be reconstructed later.
To decode the object, the corresponding initializer initWithCoder: in Objective-C or the initializer init(coder:) in Swift
In implementing encodeWithCoder, each property should be encoded with a key using the appropriate coder method,
Keyed archivers (NSKeyedArchiver) are the common form of archiving and rely on string keys to pair with
In Swift, the method is named encode(with coder: NSCoder) and the decoding initializer is init(coder: NSCoder).