forKey
forKey is a naming convention used in several programming APIs to indicate the key that identifies a value within a mapping, such as a dictionary or a coding container. It signals that the corresponding argument specifies which value to retrieve, store, or encode.
In the Cocoa and Cocoa Touch ecosystems, forKey appears in many core APIs. For example, NSDictionary and
The forKey pattern emphasizes a mapping from a key to a value rather than a positional access.
In modern Swift, dictionaries are commonly accessed via subscripting, but when interoperating with Objective-C APIs or
See also: objectForKey:, valueForKey:, encodeObject:forKey:, decodeObjectForKey:, user defaults access patterns.