---
title: "object(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nslocale/object(forkey:)"
---

# object(forKey:)

Returns the value of the component corresponding to the specified key.

## Declaration

```swift
func object(forKey key: NSLocale.Key) -> Any?
```

## Parameters

- `key`: The component for which to return the corresponding value. For possible values, see doc://com.apple.foundation/documentation/Foundation/NSLocale/Key.

## Return Value

Return Value The object corresponding to key.

## See Also

### Accessing Locale Information by Key

- [displayName(forKey:value:)](foundation/nslocale/displayname(forkey:value:).md)
- [NSLocale.Key](foundation/nslocale/key.md)
