---
title: "setValue(forKey:to:)"
framework: swiftdata
role: symbol
role_heading: Instance Method
path: "swiftdata/backingdata/setvalue(forkey:to:)-4d7yr"
---

# setValue(forKey:to:)

## Declaration

```swift
func setValue<Value>(forKey: KeyPath<Self.Model, Value>, to newValue: Value) where Value : PersistentModel
```
