---
title: "coerceValue(_:forKey:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/coercevalue(_:forkey:)"
---

# coerceValue(_:forKey:)

Uses type info from the class description and NSScriptCoercionHandler to attempt to convert value for key to the proper type, if necessary.

## Declaration

```swift
func coerceValue(_ value: Any?, forKey key: String) -> Any?
```

## Discussion

Discussion The method coerceValueFor<Key>: is used if it exists.
