MotionSupport
@MainActor
public struct MotionSupport
This struct provides utility methods for Motion classes.
-
Registers an
Additive
motion. Any custom classes that conform to theAdditive
protocol should register their motion object.Declaration
Swift
@MainActor public static func register(additiveMotion motion: Additive) -> UInt
Parameters
additiveMotion
The
Additive
object to register.Return Value
An operation ID that should be assigned to the
Additive
object’soperationID
property. -
Removes an
Additive
motion from the registered list. Any custom classes that conform to theAdditive
protocol should call this method when it has completed its motion.Declaration
Swift
@MainActor public static func unregister(additiveMotion motion: Additive)
Parameters
additiveMotion
The
Additive
object to remove. -
Returns the ending value of the most recently started
Additive
motion operation for the specified object and keyPath. In order to participate in additive motion with otherAdditive
objects, custom objects should use this method to set a starting value.Example Usage
if let last_target_value = MotionSupport.targetValue(forObject: unwrapped_object, keyPath: property.path) { properties[index].start = last_target_value }
Declaration
Swift
@MainActor public static func targetValue(forObject object: AnyObject, keyPath path: String) -> Double?
Parameters
forObject
The object whose property value should be queried.
keyPath
The keypath of the target property, relative to the object.
Return Value
The ending value. Returns
nil
if noAdditive
object is targeting this property.
-
Attempts to cast a generic object to a Double value.
Declaration
Swift
@MainActor public static func cast(_ number: AnyObject) -> Double?
Parameters
number
The object to case.
Return Value
A Double value, if the cast succeeded.
-
Utility method which determines whether the value is of the specified type.
Declaration
Swift
@MainActor public static func matchesType(forValue value: Any, typeToMatch matchType: Any.Type) -> Bool
-
Utility method which determines whether the value is of the specified Objective-C type.
Declaration
Swift
@MainActor public static func matchesObjCType(forValue value: NSValue, typeToMatch matchType: UnsafePointer<Int8>) -> Bool
-
Builds and returns a
PropertyData
object if the values you supply pass one of the following tests: 1) there’s a specified start value and that value is different than either the original value or the ending value, or 2) there’s just an original value and that value is different than the ending value, or 3) there’s no start value passed in, which will return aPropertyData
object with only an end value. In cases 1 and 2, aPropertyData
object with both start and end values will be returned. In the third case, aPropertyData
object that only has an ending value will be returned. If all those tests fail, no object will be returned.Declaration
Swift
@MainActor public static func buildPropertyData(path: String, originalValue: Double? = nil, startValue: Double?, endValue: Double) -> PropertyData?
Parameters
path
A base path to be used for the
PropertyData
‘spath
property.originalValue
An optional value representing the current value of the target object property.
startValue
An optional value to be supplied to the
PropertyData
‘sstart
property.endValue
A value to be supplied to the
PropertyData
‘send
property.Return Value
An optional
PropertyData
object using the supplied values.