decodeObjectForKey
decodeObjectForKey is a method defined on NSCoder and its concrete subclass NSKeyedUnarchiver. It is used to retrieve an object that was previously encoded with encodeObject:forKey: by supplying the same key. The method reads the encoded data and returns the decoded object, or nil if the data cannot be decoded or the key is not present in the archive.
In practice, decodeObjectForKey takes a key, which is an NSString, and returns an id (Objective-C) or Any?
Common usage examples include decoding objects that were previously encoded with encodeObject:forKey:, such as user records
Security considerations are important when unarchiving. If secure coding is enabled, developers should use methods that
See also: NSCoder, NSKeyedUnarchiver, encodeObject:forKey:, NSSecureCoding, decodeObjectOfClass:forKey:, decodeObjectOfClasses:forKey:.