ValueAssistant

@MainActor
public protocol ValueAssistant

This protocol defines methods and properties that must be adopted for any value assistant.

  • This method returns an array of PropertyData instances based on the values of the provided object.

    Declaration

    Swift

    @MainActor
    func generateProperties(targetObject target: AnyObject, propertyStates: PropertyStates) throws -> [PropertyData]

    Parameters

    targetObject

    A supported object to generate PropertyData instances from.

    propertyStates

    A model object representing property states for this value transformation.

    Return Value

    An array of PropertyData instances representing the values of the provided object.

  • This method replaces an element of an AnyObject subclass by assigning new values.

    Declaration

    Swift

    @MainActor
    func updateValue(inObject object: Any, newValues: Dictionary<String, Double>) -> NSObject?

    Parameters

    object

    The object that should be updated.

    newValues

    A dictionary of keyPaths and associated values of the object to be updated.

    Return Value

    An updated version of the object, if the object property was found and is supported.

  • This method retrieves the current value of the target object being moved (as opposed to the saved value within a PropertyData instance).

    Default Implementation

    Declaration

    Swift

    @MainActor
    func retrieveCurrentObjectValue(forProperty property: PropertyData) -> Double?

    Parameters

    property

    The PropertyData instance whose target object’s value should be queried.

    Return Value

    The retrieved value of the target object.

  • This method retrieves the value of a supported AnyObject type.

    Declaration

    Swift

    @MainActor
    func retrieveValue(inObject object: Any, keyPath path: String) throws -> Double?

    Parameters

    object

    The object whose property value should be retrieved.

    path

    The key path of the object property to be updated. If object is an NSValue instance, the path should correspond to an internal struct value path. E.g. a NSValue instance containing a NSRect might have a path property of “origin.x”.

    Return Value

    The retrieved value, if the object property was found and is supported.

  • This method calculates a new value an object property.

    Declaration

    Swift

    @MainActor
    func calculateValue(forProperty property: PropertyData, newValue: Double) -> NSObject?

    Parameters

    property

    The PropertyData instance whose property should be calculated.

    newValue

    The new value to be applied to the object property.

    Return Value

    An updated version of the object, 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: AnyObject) -> 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 to updateValue are added to the existing value instead of replacing it. The default is false.

    Seealso

    additiveWeighting

    Declaration

    Swift

    @MainActor
    var additive: 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 when additive is set to true. The default value is 1.0.

    Seealso

    additive

    Declaration

    Swift

    @MainActor
    var additiveWeighting: Double { get set }

ValueAssistant protocol

  • applyTo(value:newValue:) Extension method

    Applies a new Double value to an existing one, either adding to it if additive mode is active, or simply replacing it.

    Declaration

    Swift

    @MainActor
    func applyTo(value: inout Double, newValue: Double)

    Parameters

    value

    The Double value to modify.

    newValue

    The Double value used to modify the existing value.

  • applyTo(value:newValue:) Extension method

    Applies a new CGFloat value to an existing value, either adding to it if additive mode is active, or simply replacing it.

    Declaration

    Swift

    @MainActor
    func applyTo(value: inout CGFloat, newValue: CGFloat)

    Parameters

    value

    The CGFloat value to modify.

    newValue

    The CGFloat value used to modify the existing value.

  • lastComponent(forPath:) Extension method

    Returns the last component in a period-delimited String path.

    Declaration

    Swift

    @MainActor
    func lastComponent(forPath path: String) -> String?

    Parameters

    path

    The String path to search.

    Return Value

    The path component, if one was found.

  • lastTwoComponents(forPath:) Extension method

    Returns the last two components in a period-delimited String path.

    Declaration

    Swift

    @MainActor
    func lastTwoComponents(forPath path: String) -> [String]?

    Parameters

    path

    The String path to search.

    Return Value

    An array of path components, if any were found.