---
title: "setValue(_:forUndefinedKey:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/setvalue(_:forundefinedkey:)"
---

# setValue(_:forUndefinedKey:)

Invoked by setValue(_:forKey:) when it finds no property for a given key.

## Declaration

```swift
func setValue(_ value: Any?, forUndefinedKey key: String)
```

## Parameters

- `value`: The value for the key identified by key.
- `key`: A string that is not equal to the name of any of the receiver’s properties.

## Discussion

Discussion Subclasses can override this method to handle the request in some other way. The default implementation raises an NSUndefinedKeyException.

## See Also

### Related Documentation

- [value(forUndefinedKey:)](objectivec/nsobject-swift.class/value(forundefinedkey:).md)

### Setting Values

- [setValue(_:forKeyPath:)](objectivec/nsobject-swift.class/setvalue(_:forkeypath:).md)
- [setValuesForKeys(_:)](objectivec/nsobject-swift.class/setvaluesforkeys(_:).md)
- [setNilValueForKey(_:)](objectivec/nsobject-swift.class/setnilvalueforkey(_:).md)
- [setValue(_:forKey:)](objectivec/nsobject-swift.class/setvalue(_:forkey:).md)
