Class: MotionBindable::Strategies::UITextField
Instance Attribute Summary
#bound, #object
Instance Method Summary
collapse
#attribute, #attribute=, #bind, find_by_reference, #initialize, register_strategy
Instance Method Details
#on_bind ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/strategies/ui_text_field.rb', line 7
def on_bind
refresh
NSNotificationCenter.defaultCenter.addObserver(
self, selector: :on_bound_change,
name: UITextFieldTextDidChangeNotification, object: bound
)
observe(object, @attr_name) { |_, _| on_object_change }
end
|
#on_bound_change ⇒ Object
Also known as:
refresh
20
21
22
|
# File 'lib/strategies/ui_text_field.rb', line 20
def on_bound_change
self.attribute = bound.text
end
|
#on_object_change ⇒ Object
24
25
26
|
# File 'lib/strategies/ui_text_field.rb', line 24
def on_object_change
@bound.text = attribute
end
|
#unbind ⇒ Object
28
29
30
31
|
# File 'lib/strategies/ui_text_field.rb', line 28
def unbind
App.notification_center.unobserve(@bound_observer)
unobserve(object, @attr_name)
end
|