Type Method 型メソッド

keyPathsForValuesAffectingValue(forKey:)

Returns a set of key paths for properties whose values affect the value of the specified key.

Declaration 宣言

class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String>

Parameters パラメータ

key

The key whose value is affected by the key paths.

Discussion 解説

When an observer for the key is registered with an instance of the receiving class, key-value observing itself automatically observes all of the key paths for the same instance, and sends change notifications for the key to the observer when the value for any of those key paths changes.

The default implementation of this method searches the receiving class for a method whose name matches the pattern +keyPathsForValuesAffecting<Key>, and returns the result of invoking that method if it is found. Any such method must return an NSSet. If no such method is found, an NSSet that is computed from information provided by previous invocations of the now-deprecated setKeys:triggerChangeNotificationsForDependentKey: method is returned, for backward binary compatibility.

You can override this method when the getter method of one of your properties computes a value to return using the values of other properties, including those that are located by key paths. Your override should typically call super and return a set that includes any members in the set that result from doing that (so as not to interfere with overrides of this method in superclasses).

See Also 参照

Observing Customization