class MotionBindable::Strategies::UITextField

Public Instance Methods

on_bound_change(new = nil) click to toggle source
# File lib/strategies/ui_text_field.rb, line 18
def on_bound_change(new = nil)
  self.attribute = (new || bound.text)
end
on_object_change(new = nil) click to toggle source
# File lib/strategies/ui_text_field.rb, line 22
def on_object_change(new = nil)
  @bound.text = (new || attribute)
end
start_observing_bound() click to toggle source
# File lib/strategies/ui_text_field.rb, line 5
def start_observing_bound
  @bound_observer = NSNotificationCenter.defaultCenter.addObserverForName(
    UITextFieldTextDidChangeNotification,
    object: bound,
    queue: nil,
    usingBlock: proc { |_| on_bound_change }
  )
end
start_observing_object() click to toggle source
# File lib/strategies/ui_text_field.rb, line 14
def start_observing_object
  observe_object { |_, new| on_object_change(new) }
end
unbind() click to toggle source
Calls superclass method
# File lib/strategies/ui_text_field.rb, line 26
def unbind
  NSNotificationCenter.defaultCenter.removeObserver(@bound_observer)
  stop_observe_object
  super
end