ValueAssistant
@MainActor
public protocol ValueAssistant<TargetType>
This protocol defines methods and properties that must be adopted for any value assistant.
-
Undocumented
Declaration
Swift
associatedtype TargetType : AnyObject
-
This method generates and returns an array of
PropertyData
instances based on the providedMotionState
object.Declaration
Swift
@MainActor func generateProperties<StateType>(targetObject target: TargetType, state: MotionState<TargetType, StateType>) throws -> [PropertyData<TargetType>]
Parameters
targetObject
The root object of the key path which targets the state object.
state
Represents an object state and associated metadata from which this method should build
PropertyData
objects.Return Value
An array of
PropertyData
instances representing the state values of the provided object. -
This method updates a group of properties who have the same parent object.
Declaration
Swift
@MainActor func update(properties: [PropertyData<TargetType> : Double], targetObject: TargetType)
Parameters
properties
A dictionary of updated property values whose keys are
PropertyData
objects whose property should be updated.targetObject
The target object.
Return Value
An updated version of the property value, if the object property was found and is supported.
-
Verifies whether this class can update the specified object type.
Declaration
Swift
@MainActor func supports(_ object: Any) -> Bool
Parameters
object
An object to verify support for.
Return Value
A Boolean value representing whether the object is supported by this class.
-
Verifies whether this object can accept a keyPath.
Declaration
Swift
@MainActor func acceptsKeypath(_ object: AnyObject) -> Bool
Parameters
object
An object to verify support for.
Return Value
A Boolean value representing whether the object is supported by this class.
-
A Boolean which determines whether to update a value using additive updates. When the value is
true
, values passed in toupdateValue
are added to the existing value instead of replacing it. The default isfalse
.Seealso
additiveWeightingDeclaration
Swift
@MainActor var isAdditive: Bool { get set }
-
A weighting between 0.0 and 1.0 which is applied to a value updates when the ValueAssistant is updating additively. The higher the weighting amount, the more that a new value will be applied in the
updateValue
method. A value of 1.0 will apply the full value to the existing value, and a value of 0.0 will apply nothing to it.Note
This value only has an effect whenadditive
is set totrue
. The default value is 1.0.Seealso
additiveDeclaration
Swift
@MainActor var additiveWeighting: Double { get set }
-
applyAdditiveTo(value:
Extension methodnewValue: ) Applies a new
BinaryFloatingPoint
value to an existing one and returns it, either adding to it ifadditive
mode is active, or simply replacing it.Declaration
Swift
@MainActor func applyAdditiveTo<ValueType>(value: ValueType, newValue: ValueType) -> ValueType where ValueType : BinaryFloatingPoint
Parameters
value
The value to modify.
newValue
The value used to modify the existing value.
Return Value
The updated value.
-
applyAdditiveTo(value:
Extension methodnewValue: ) Applies a new
BinaryInteger
value to an existing value and returns it, either adding to it ifadditive
mode is active, or simply replacing it.Declaration
Swift
@MainActor func applyAdditiveTo<ValueType>(value: inout ValueType, newValue: ValueType) -> ValueType where ValueType : BinaryInteger
Parameters
value
The value to modify.
newValue
The value used to modify the existing value.
Return Value
The updated value.