Instance Method


Sets the value for the property identified by a given key path to a given value.


- (void)setValue:(id)value forKeyPath:(NSString *)keyPath;



The value for the property identified by keyPath.


A key path of the form relationship

.property (with one or more relationships): for example “” or “department.manager.lastName.”


The default implementation of this method gets the destination object for each relationship using valueForKey:, and sends the final object a setValue:forKey: message.

Special Considerations

When using this method, and the destination object does not implement an accessor for the value, the default behavior is for that object to retain value rather than copy or assign value.

See Also

Setting Values

- setValuesForKeysWithDictionary:

Sets properties of the receiver with values from a given dictionary, using its keys to identify the properties.

- setNilValueForKey:

Invoked by setValue:forKey: when it’s given a nil value for a scalar value (such as an int or float).

- setValue:forKey:

Sets the property of the receiver specified by a given key to a given value.

- setValue:forUndefinedKey:

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