---
title: "init(forKeyPath:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsexpression/init(forkeypath:)-1aqf5"
---

# init(forKeyPath:)

Creates an expression that invokes the value function with a specified key path.

## Declaration

```swift
init(forKeyPath keyPath: String)
```

## Parameters

- `keyPath`: The key path that the new expression should evaluate.

## Return Value

Return Value A new expression that invokes value(forKeyPath:) with keyPath.

## See Also

### Creating an Expression for a Value

- [init(forConstantValue:)](foundation/nsexpression/init(forconstantvalue:).md)
- [expressionForEvaluatedObject()](foundation/nsexpression/expressionforevaluatedobject().md)
- [init(forVariable:)](foundation/nsexpression/init(forvariable:).md)
- [init(forKeyPath:)](foundation/nsexpression/init(forkeypath:)-98by.md)
- [expressionForAnyKey()](foundation/nsexpression/expressionforanykey().md)
