Sha256: d052f3f063e21942eb387341a0731818f35e4d562cdd0eb040afaec6560f7d58
Contents?: true
Size: 803 Bytes
Versions: 1
Compression:
Stored size: 803 Bytes
Contents
module MotionBindable::Strategies class UITextField < ::MotionBindable::Strategy include MotionBindable::StrategyHelpers def start_observing_bound @bound_observer = NSNotificationCenter.defaultCenter.addObserverForName( UITextFieldTextDidChangeNotification, object: bound, queue: nil, usingBlock: proc { |_| on_bound_change } ) end def start_observing_object observe_object { |_, new| on_object_change(new) } end def on_bound_change(new = nil) self.attribute = (new || bound.text) end def on_object_change(new = nil) @bound.text = (new || attribute) end def unbind NSNotificationCenter.defaultCenter.removeObserver(@bound_observer) stop_observe_object super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
motion_bindable-0.3.0 | lib/strategies/ui_text_field.rb |