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

# value(forKeyPath:)

Returns the value for the derived property identified by a given key path.

```
func value(forKeyPath keyPath: String) -> Any?
```

## Parameters

`keyPath`

A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”.

## Return Value

The value for the derived property identified by `keyPath`.

## Discussion

The default implementation gets the destination object for each relationship using [`value(forKey:)`](/documentation/ObjectiveC/NSObject-swift.class/value(forKey:)) and returns the result of a [`value(forKey:)`](/documentation/ObjectiveC/NSObject-swift.class/value(forKey:)) message to the final object.

## See Also

[`setValue(_:forKeyPath:)`](/documentation/ObjectiveC/NSObject-swift.class/setValue(_:forKeyPath:))

Sets the value for the property identified by a given key path to a given value.



---

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)