Functions
The following functions are available globally.
-
Mechanica
‘CGFloat’ percent operator.
Declaration
Swift
public postfix func % (value: CGFloat) -> CGFloat
-
Mechanica
‘Float’ percent operator.
Declaration
Swift
public postfix func % (value: Float) -> Float
-
Mechanica
‘Double’ percent operator.
Declaration
Swift
public postfix func % (value: Double) -> Double
-
Mechanica
Sets an associated value for a given object using a given key and association policy.
Declaration
Swift
public func setAssociatedValue<T>(_ value: T?, forObject object: Any, usingKey key: UnsafeRawPointer, andPolicy policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
Parameters
value
The value to associate with the key key for object. Pass nil to clear an existing association.
object
The source object for the association.
key
The key for the association.
policy
The policy for the association.
-
Mechanica
Returns the value associated with a given object for a given key.
Declaration
Swift
public func getAssociatedValue<T>(forObject object: Any, usingKey key: UnsafeRawPointer) -> T?
Parameters
object
The source object for the association.
key
The key for the association.
Return Value
The value associated with the key for object.
-
Mechanica
Removes an associated value for a given object using a given key and association policy.
Declaration
Swift
public func removeAssociatedValue(forObject object: Any, usingKey key: UnsafeRawPointer, andPolicy policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
Parameters
object
The source object for the association.
key
The key for the association.
policy
The policy for the association.
-
Mechanica
Returns the type name as
String
.Declaration
Swift
public func typeName(of some: Any) -> String
-
Mechanica
Optional-string-coalescing operator.
The ??? operator takes any
See moreoptional
on its left side and adefault
string value on the right, returning a string. If the optional value is non-nil, it unwraps it and returns its string description, otherwise it returns the default value.Declaration
Swift
public func ??? <T>(optional: T?, defaultValue: @autoclosure () -> String) -> String