zoukankan      html  css  js  c++  java
  • RAC转换传统的通信

    ///////////////////各种机制转信号///////////////////////////////

    1.UI事件

    [self.logInButton rac_signalForControlEvents:UIControlEventTouchUpInside]

    2.Delegate回调

    [self rac_signalForSelector:@selector(flickrAPIRequest:didCompleteWithResponse:) fromProtocol:@protocol(OFFlickrAPIRequestDelegate)];

    3.Notificaiton

    [NSNotificationCenter.defaultCenter rac_addObserverForName:UserDidLogOutNotification object:nil]

    4.KVO观察

    [RACObserve(self, username)]

    5.Target-Action

    [self rac_signalForSelector:@selector(didChangeValueForKey:)]

    ////////////////////常用情景//////////////////////////////////

     6.AlertView

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:@"Alert" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:@"NO", nil];
    [[alertView rac_buttonClickedSignal] subscribeNext:^(NSNumber *indexNumber) {
        if ([indexNumber intValue] == 1) {
            NSLog(@"you touched NO");
        } else {
            NSLog(@"you touched YES");
        }
    }];
    [alertView show];

     7.Gesture

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init]; 
        tapGesture.numberOfTapsRequired = 2; 
        [[tapGesture rac_gestureSignal] subscribeNext:^(id x) { 
            [self.viewModel.likeCommand execute:nil]; 
        }]; 
  • 相关阅读:
    【Git】rebase 用法小结(转)
    修饰符访问权限。
    throws与throw关键字。
    多线程,同步代码块。
    多线程,设置线程的优先级。
    多线程,加入线程。
    多线程,守护线程。
    多线程,休眠线程。
    多线程,获取当前线程的对象。
    多线程获取名字和设置名字。
  • 原文地址:https://www.cnblogs.com/guoxiaoqian/p/4683350.html
Copyright © 2011-2022 走看看