ValueAssociable

public protocol ValueAssociable

Mechanica

Classes adopting this protocol can associate values to the object itself.

  • Mechanica

    Sets an associated value using a given key and association policy.

    Default Implementation

    Mechanica

    Removes an associated value using a given key and association policy.

    Declaration

    Swift

    func set<T>(associatedValue value: T?, forKey key: UnsafeRawPointer, andPolicy policy: objc_AssociationPolicy)

    Parameters

    value

    The value to associate with the key key for object. Pass nil to clear an existing association.

    key

    The key for the association.

    policy

    The policy for the association.

  • getAssociatedValue(forKey:) Default implementation

    Mechanica

    Returns the value associated for a given key.

    Default Implementation

    Mechanica

    Removes an associated value using a given key and association policy.

    Declaration

    Swift

    func getAssociatedValue<T>(forKey key: UnsafeRawPointer) -> T?

    Parameters

    key

    The key for the association.

    Return Value

    the value associated with the key.

  • Mechanica

    Removes an associated value using a given key and association policy.

    Default Implementation

    Mechanica

    Removes an associated value using a given key and association policy.

    Declaration

    Swift

    func removeAssociatedValue(forKey key: UnsafeRawPointer, andPolicy policy: objc_AssociationPolicy)

    Parameters

    key

    The key for the association.

    policy

    The policy for the association.