Skip to content

Instantly share code, notes, and snippets.

@xareelee
xareelee / UIButton+RACSupportForTitle.md
Last active November 25, 2016 03:56
Use RAC() macro for binding a UIButton title

You can't use RAC() directly on a UIButton because of the UIKit design:

RAC(self.button.titleLabel, text) = titleSignal;  // Don't do this.

One of the solutions is using dynamic property to support RAC() binding macro:

// .h
@xareelee
xareelee / DismissKeyboardWhenTappingContentView.md
Last active August 29, 2015 14:26
Dismiss keyboard when tapping table view (or content view) using ReactiveCocoa
- (void)viewDidLoad
{
  [super viewDidLoad];
  @weakify(self);
  
  // Add a gesture recognizer to a view
  UITapGestureRecognizer *tap = [UITapGestureRecognizer new];
  [tap.rac_gestureSignal subscribeNext:^(id x) {
 @strongify(self);