如何将 UISwitch.onNSUserDefaults 中的键值绑定(bind)?

最佳答案

您可以通过以下方式绑定(bind)它们(双向绑定(bind)):

RACChannelTerminal *switchTerminal = self.someSwitch.rac_newOnChannel;
RACChannelTerminal *defaultsTerminal = [[NSUserDefaults standardUserDefaults] rac_channelTerminalForKey:@"someBoolKey"];

[switchTerminal subscribe:defaultsTerminal];
[defaultsTerminal subscribe:switchTerminal];

开关的 on 状态从用户默认值或 NO 中的值开始。

关于objective-c - 使用 ReactiveCocoa 将 UISwitch 的状态绑定(bind)到 NSUserDefaults,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23107136/

10-10 20:32
查看更多