class AnyKeyPath A type-erased key path, from any root type to any resulting value type. Inheritance Equatable, Hashable, _AppendKeyPath View Protocol Hierarchy → Import import Swift Static Variables static var rootType: Any.Type The root type for this key path. Declaration static var rootType: Any.Type { get } static var valueType: Any.Type The value type for this key path. Declaration static var valueType: Any.Type { get } Instance Variables var hashValue: Int The hash value. Declaration var hashValue: Int { get } Instance Methods func appending(_:) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Appending the key path passed as path is successful only if the root type for path matches this key path's value type. This example creates key paths from Array<Int> to String and from String to Int, and then tries appending each to the other: let arrayDescription: AnyKeyPath = \Array<Int>.description let stringLength: AnyKeyPath = \String.count // Creates a key path from `Array<Int>` to `Int` let arrayDescriptionLength = arrayDescription.appending(path: stringLength) let invalidKeyPath = stringLength.appending(path: arrayDescription) // invalidKeyPath == nil The second call to appending(path:) returns nil because the root type of arrayDescription, Array<Int>, does not match the value type of stringLength, Int. path: The key path to append. Returns: A key path from the root of this key path and the value type of path, if path can be appended. If path can't be appended, returns nil. Declaration func appending(path: AnyKeyPath) -> AnyKeyPath? Declared In _AppendKeyPath func appending<Root>(_: AnyKeyPath) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Appending the key path passed as path is successful only if the root type for path matches this key path's value type. This example creates key paths from Array<Int> to String and from String to Int, and then tries appending each to the other: let arrayDescription: PartialKeyPath<Array<Int>> = \.description let stringLength: PartialKeyPath<String> = \.count // Creates a key path from `Array<Int>` to `Int` let arrayDescriptionLength = arrayDescription.appending(path: stringLength) let invalidKeyPath = stringLength.appending(path: arrayDescription) // invalidKeyPath == nil The second call to appending(path:) returns nil because the root type of arrayDescription, Array<Int>, does not match the value type of stringLength, Int. path: The key path to append. Returns: A key path from the root of this key path and the value type of path, if path can be appended. If path can't be appended, returns nil. Declaration func appending<Root>(path: AnyKeyPath) -> PartialKeyPath<Root>? where AnyKeyPath == PartialKeyPath<Root> Declared In _AppendKeyPath func appending<Root, Value, AppendedValue>(_: KeyPath<Value, AppendedValue>) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Calling appending(path:) results in the same key path as if the given key path had been specified using dot notation. In the following example, keyPath1 and keyPath2 are equivalent: let arrayDescription = \Array<Int>.description let keyPath1 = arrayDescription.appending(path: \String.count) let keyPath2 = \Array<Int>.description.count path: The key path to append. Returns: A key path from the root of this key path to the value type of path. Declaration func appending<Root, Value, AppendedValue>(path: KeyPath<Value, AppendedValue>) -> KeyPath<Root, AppendedValue> where AnyKeyPath : KeyPath<Root, Value> Declared In _AppendKeyPath func appending<Root, Value, AppendedValue>(_: ReferenceWritableKeyPath<Value, AppendedValue>) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Calling appending(path:) results in the same key path as if the given key path had been specified using dot notation. path: The key path to append. Returns: A key path from the root of this key path to the value type of path. Declaration func appending<Root, Value, AppendedValue>(path: ReferenceWritableKeyPath<Value, AppendedValue>) -> ReferenceWritableKeyPath<Root, AppendedValue> where AnyKeyPath == KeyPath<Root, Value> Declared In _AppendKeyPath func appending<Root, Value, AppendedValue>(_: WritableKeyPath<Value, AppendedValue>) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Calling appending(path:) results in the same key path as if the given key path had been specified using dot notation. path: The key path to append. Returns: A key path from the root of this key path to the value type of path. Declaration func appending<Root, Value, AppendedValue>(path: WritableKeyPath<Value, AppendedValue>) -> WritableKeyPath<Root, AppendedValue> where AnyKeyPath == WritableKeyPath<Root, Value> Declared In _AppendKeyPath func appending<Root, AppendedRoot, AppendedValue>(_: KeyPath<AppendedRoot, AppendedValue>) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Appending the key path passed as path is successful only if the root type for path matches this key path's value type. This example creates a key path from Array<Int> to String, and then tries appending compatible and incompatible key paths: let arrayDescription: PartialKeyPath<Array<Int>> = \.description // Creates a key path from `Array<Int>` to `Int` let arrayDescriptionLength = arrayDescription.appending(path: \String.count) let invalidKeyPath = arrayDescription.appending(path: \Double.isZero) // invalidKeyPath == nil The second call to appending(path:) returns nil because the root type of the path parameter, Double, does not match the value type of arrayDescription, String. path: The key path to append. Returns: A key path from the root of this key path to the value type of path, if path can be appended. If path can't be appended, returns nil. Declaration func appending<Root, AppendedRoot, AppendedValue>(path: KeyPath<AppendedRoot, AppendedValue>) -> KeyPath<Root, AppendedValue>? where AnyKeyPath == PartialKeyPath<Root> Declared In _AppendKeyPath func appending<Root, AppendedRoot, AppendedValue>(_: ReferenceWritableKeyPath<AppendedRoot, AppendedValue>) Returns a new key path created by appending the given key path to this one. Use this method to extend this key path to the value type of another key path. Appending the key path passed as path is successful only if the root type for path matches this key path's value type. path: The reference writeable key path to append. Returns: A key path from the root of this key path to the value type of path, if path can be appended. If path can't be appended, returns nil. Declaration func appending<Root, AppendedRoot, AppendedValue>(path: ReferenceWritableKeyPath<AppendedRoot, AppendedValue>) -> ReferenceWritableKeyPath<Root, AppendedValue>? where AnyKeyPath == PartialKeyPath<Root> Declared In _AppendKeyPath func hash(into:) Hashes the essential components of this value by feeding them into the given hasher. hasher: The hasher to use when combining the components of this instance. Declaration func hash(into hasher: inout Hasher)