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

# value(forUndefinedKey:)

Invoked by value(forKey:) when it finds no property corresponding to a given key.

## Declaration

```swift
func value(forUndefinedKey key: String) -> Any?
```

## Parameters

- `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 return an alternate value for undefined keys. The default implementation raises an NSUndefinedKeyException.

## See Also

### Related Documentation

- [setValue(_:forUndefinedKey:)](objectivec/nsobject-swift.class/setvalue(_:forundefinedkey:).md)

### Getting Values

- [value(forKey:)](objectivec/nsobject-swift.class/value(forkey:).md)
- [value(forKeyPath:)](objectivec/nsobject-swift.class/value(forkeypath:).md)
- [dictionaryWithValues(forKeys:)](objectivec/nsobject-swift.class/dictionarywithvalues(forkeys:).md)
- [mutableArrayValue(forKey:)](objectivec/nsobject-swift.class/mutablearrayvalue(forkey:).md)
- [mutableArrayValue(forKeyPath:)](objectivec/nsobject-swift.class/mutablearrayvalue(forkeypath:).md)
- [mutableSetValue(forKey:)](objectivec/nsobject-swift.class/mutablesetvalue(forkey:).md)
- [mutableSetValue(forKeyPath:)](objectivec/nsobject-swift.class/mutablesetvalue(forkeypath:).md)
- [mutableOrderedSetValue(forKey:)](objectivec/nsobject-swift.class/mutableorderedsetvalue(forkey:).md)
- [mutableOrderedSetValue(forKeyPath:)](objectivec/nsobject-swift.class/mutableorderedsetvalue(forkeypath:).md)
