84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
假设有两个 Siwtch 需要互异绑定,用 rac 该怎么写?
UISwitch *switch1; UISwitch *switch2; switch1.action = { switch2.on = !switch2.on; } switch2.action = { switch1.on = !switch1.on; }
认证0级讲师
Is this so?
switch1.on = YES; switch2.on = NO; RACChannelTerminal *t1 = switch1.rac_newOnChannel; RACChannelTerminal *t2 = switch2.rac_newOnChannel; [[t1 map:^id(NSNumber *on) { return @(![on boolValue]); }] subscribe:t2]; [[t2 map:^id(NSNumber *on) { return @(![on boolValue]); }] subscribe:t1];
Found a solution:
RACChannelTerminal *aButtonChannel = [aButton rac_newSelectedChannel]; RACChannelTerminal *bButtonChannel = [bButton rac_newSelectedChannel]; [[aButtonChannel not] subscribe:bButtonChannel]; [[bButtonChannel not] subscribe:aButtonChannel];
Is this so?
Found a solution: