ValueAssistant
public protocol ValueAssistant
This protocol defines methods and properties that must be adopted for any value assistant.
-
Declaration
Swift
init()
-
This method returns an array of PropertyData instances based on the values of the provided object.
Declaration
Swift
func generateProperties(targetObject target: AnyObject, propertyStates: PropertyStates) throws -> [PropertyData]
Parameters
object
A supported object to generate PropertyData instances from.
path
The base keyPath which points to the target object.
target
The object whose properties should be modified.
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
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.
-
retrieveCurrentObjectValue(forProperty:)
Default implementationThis 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
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
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 oforigin.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
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
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
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
var additive: Bool
-
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.Seealso
additiveDeclaration
Swift
var additiveWeighting: Double
-
applyTo(value:newValue:)
Extension methodDeclaration
Swift
public func applyTo(value: inout Double, newValue: Double)
-
applyTo(value:newValue:)
Extension methodDeclaration
Swift
public func applyTo(value: inout CGFloat, newValue: CGFloat)
-
lastComponent(forPath:)
Extension methodDeclaration
Swift
public func lastComponent(forPath path: String) -> String