Undefined Title

Undefined Title

Toggle UIControl status with ReacativeCocoa

We frequently need a case that enables button denpends on a condition like text view is filled with more than one character. Then there is a way to implement easily using ReactiveCocoa.

rac_textSignal property helps us to toggle butotn status like below.

#import <ReactiveCocoa.h>

UITextView _text = ...;
UIButton _ok = ...;

// Enable ok button when the length of text view content is more than zero.
[_text.rac_textSignal subscribeNext:^(NSString *x) {
    _ok.enabled = [x length] > 0;
}];