Edytuj

Udostępnij za pośrednictwem


NSObject.ValueForKeyPath(NSString) Method

Definition

Returns the value of a property that can be reached using a keypath.

[Foundation.Export("valueForKeyPath:")]
public virtual Foundation.NSObject ValueForKeyPath (Foundation.NSString keyPath);
abstract member ValueForKeyPath : Foundation.NSString -> Foundation.NSObject
override this.ValueForKeyPath : Foundation.NSString -> Foundation.NSObject

Parameters

keyPath
NSString

Key-path to use to perform the value lookup. The keypath consists of a series of lowercase ASCII-strings with no spaces in them separated by dot characters.

Returns

An NSObject containing the value for the specified keypath.

Attributes

Remarks

The keypath is separated by dots, and each component is used to lookup a specific key on the object. The process is repeated on each returning object until the last element is processed.

If a component of the key path is not found, the method ValueForUndefinedKey(NSString) is invoked, and its default implementation raises an Objective-C exception. Subclasses can alter this behavior by overriding that method.

string GetMobilePhone (Order order)
{
	return (string) order.ValueForKeyPath ("user.address.phone.mobile");
}

Applies to