Contents

setValue(_:forKeyPath:)

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

Declaration

func setValue(_ value: Any?, forKeyPath keyPath: String)

Parameters

  • value:

    The value for the property identified by keyPath.

  • keyPath:

    A key path of the form relationship.property (with one or more relationships): for example “department.name” or “department.manager.lastName.”

Discussion

The default implementation of this method gets the destination object for each relationship using value(forKey:), 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

Related Documentation

Setting Values