Sha256: 3f19d51537d4997bb6a6bdcac5a6d84be3e12cf7cf9769b90250b7d64f7fee4d

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module MotionBindable::Strategies

  class UILabel < ::MotionBindable::Strategy

    def start_observing_object
      # Observe the attribute
      object.addObserver(
        self,
        forKeyPath: attr_name,
        options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld,
        context: nil
      )
    end

    def on_object_change(new = nil)
      @bound.text = (new || attribute)
      @bound.setNeedsDisplay
    end

    def observeValueForKeyPath(_, ofObject: _, change: _, context: _)
      on_object_change
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion_bindable-0.2.4 lib/strategies/ui_label.rb
motion_bindable-0.2.3 lib/strategies/ui_label.rb