---
title: NSKeyValueCoding
framework: objectivec
role: collectionGroup
role_heading: API Collection
path: objectivec/nskeyvaluecoding
---

# NSKeyValueCoding

A mechanism by which you can access the properties of an object indirectly by name or key.

## Overview

Overview The basic methods for accessing an object’s values are setValue(_:forKey:), which sets the value for the property identified by the specified key, and value(forKey:), which returns the value for the property identified by the specified key. Thus, all of an object’s properties can be accessed in a consistent manner. The default implementation relies on the accessor methods normally implemented by objects (or to access instance variables directly if need be).

## Topics

### 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)
- [value(forUndefinedKey:)](objectivec/nsobject-swift.class/value(forundefinedkey:).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)

### 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)
- [setValue(_:forUndefinedKey:)](objectivec/nsobject-swift.class/setvalue(_:forundefinedkey:).md)

### Changing Default Behavior

- [accessInstanceVariablesDirectly](objectivec/nsobject-swift.class/accessinstancevariablesdirectly.md)

### Validation

- [validateValue(_:forKey:)](objectivec/nsobject-swift.class/validatevalue(_:forkey:).md)
- [validateValue(_:forKeyPath:)](objectivec/nsobject-swift.class/validatevalue(_:forkeypath:).md)

### Deprecated Methods

- [useStoredAccessor()](objectivec/nsobject-swift.class/usestoredaccessor().md)
- [handleQuery(withUnboundKey:)](objectivec/nsobject-swift.class/handlequery(withunboundkey:).md)
- [handleTakeValue(_:forUnboundKey:)](objectivec/nsobject-swift.class/handletakevalue(_:forunboundkey:).md)
- [storedValue(forKey:)](objectivec/nsobject-swift.class/storedvalue(forkey:).md)
- [takeStoredValue(_:forKey:)](objectivec/nsobject-swift.class/takestoredvalue(_:forkey:).md)
- [takeValues(from:)](objectivec/nsobject-swift.class/takevalues(from:).md)
- [takeValue(_:forKeyPath:)](objectivec/nsobject-swift.class/takevalue(_:forkeypath:).md)
- [takeValue(_:forKey:)](objectivec/nsobject-swift.class/takevalue(_:forkey:).md)
- [unableToSetNil(forKey:)](objectivec/nsobject-swift.class/unabletosetnil(forkey:).md)
- [values(forKeys:)](objectivec/nsobject-swift.class/values(forkeys:).md)

### Constants

- [Key Value Coding Exception Names](objectivec/key-value-coding-exception-names.md)
- [NSUndefinedKeyException userInfo Keys](objectivec/nsundefinedkeyexception-userinfo-keys.md)
- [NSKeyValueValidationError](foundation/nskeyvaluevalidationerror-swift.var.md)

## See Also

### Related Documentation

- [Key-Value Coding Programming Guide](apple-archive/documentation/Cocoa/Conceptual/KeyValueCoding.md)

### Key-Value Coding

- [NSKeyValueBindingCreation](objectivec/nskeyvaluebindingcreation.md)
- [NSScriptKeyValueCoding](objectivec/nsscriptkeyvaluecoding.md)
- [NSScriptKeyValueCoding Exception Names](objectivec/nsscriptkeyvaluecoding-exception-names.md)
