iOS 链式编程思想
链式编程思想不用啰嗦哈,
例如将计算方法,用链方式串联起来,实现可以参考下
github: RAC_链式编程
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. int iResult = [NSObject makeCaculators:^(CaculatorMaker *make) { make.add(1).add(2).add(3).divide(2); }]; NSLog(@" 1===== %d",iResult); CaculatorMaker *maker = [[CaculatorMaker alloc]init]; NSInteger reslut = [[[maker caculator:^int(int result) { result += 2; result *= 5; return result; }] equle:^BOOL(int result) { return result = 10; }] isEqule]; NSLog(@" 2===== %ld",(long)reslut); }
注:
reactiveCocoa的常用语法
github: reactiveCocoa