DynamicProperty

public final class DynamicProperty<Value>: MutablePropertyProtocol

Wraps a dynamic property, or one defined in Objective-C, using Key-Value Coding and Key-Value Observing.

Use this class only as a last resort! MutableProperty is generally better unless KVC/KVO is required by the API you’re using (for example, NSOperation).

  • The current value of the property, as read and written using Key-Value Coding.

    Declaration

    Swift

    public var value: Value?
  • The lifetime of the property.

    Declaration

    Swift

    public var lifetime: Lifetime
  • A producer that will create a Key-Value Observer for the given object, send its initial value then all changes over time, and then complete when the observed object has deallocated.

    Important

    This only works if the object given to init() is KVO-compliant. Most UI controls are not!

    Declaration

    Swift

    public var producer: SignalProducer<Value?, NoError>
  • A producer that will create a Key-Value Observer for the given object, send its initial value then all changes over time, and then complete when the observed object has deallocated.

    Important

    This only works if the object given to init() is KVO-compliant. Most UI controls are not!

    Declaration

    Swift

    public private(set) lazy var signal: Signal<Value?, NoError> =
  • Initializes a property that will observe and set the given key path of the given object. The generic type Value can be any Swift type, and will be bridged to Objective-C via Any.

    Important

    object must support weak references!

  • parameters:

    • object: An object to be observed.
    • keyPath: Key path to observe on the object.
  • Declaration

    Swift

    public init(object: NSObject?, keyPath: String)

    Parameters

    object

    An object to be observed.

    keyPath

    Key path to observe on the object.