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

# object(forKey:)

Returns the value associated with a given key.

## Declaration

```swift
func object(forKey aKey: Any) -> Any?
```

## Parameters

- `aKey`: The key for which to return the corresponding value.

## Return Value

Return Value The value associated with aKey, or nil if no value is associated with aKey.

## See Also

### Accessing Keys and Values

- [allKeys](foundation/nsdictionary/allkeys.md)
- [allKeys(for:)](foundation/nsdictionary/allkeys(for:).md)
- [allValues](foundation/nsdictionary/allvalues.md)
- [value(forKey:)](foundation/nsdictionary/value(forkey:).md)
- [objects(forKeys:notFoundMarker:)](foundation/nsdictionary/objects(forkeys:notfoundmarker:).md)
- [subscript(_:)](foundation/nsdictionary/subscript(_:)-52n56.md)
- [subscript(_:)](foundation/nsdictionary/subscript(_:)-1bt1b.md)
