<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/dictionaryWithValues(forKeys:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)dictionaryWithValuesForKeys:"
  },
  "title" : "dictionaryWithValues(forKeys:)"
}
-->

# dictionaryWithValues(forKeys:)

Returns a dictionary containing the property values identified by each of the keys in a given array.

```
func dictionaryWithValues(forKeys keys: [String]) -> [String : Any]
```

## Parameters

`keys`

An array containing `NSString` objects that identify properties of the receiver.

## Return Value

A dictionary containing as keys the property names in `keys`, with corresponding values being the corresponding property values.

## Discussion

The default implementation invokes [`value(forKey:)`](/documentation/ObjectiveC/NSObject-swift.class/value(forKey:)) for each key in `keys` and substitutes `NSNull` values in the dictionary for returned `nil` values.

## See Also

[`-  setValuesForKeysWithDictionary:`](/documentation/ObjectiveC/NSObject-swift.class/setValuesForKeys(_:))

Sets properties of the receiver with values from a given dictionary, using its keys to identify the properties.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)