holy_sin
V2EX  ›  问与答

RAC 双向绑定为什么不会死循环呢?

  •  1
     
  •   holy_sin · May 5, 2016 · 3234 views
    This topic created in 3692 days ago, the information mentioned may be changed or developed.
        RACChannelTerminal *switchTerminal = self.someSwitch.rac_newOnChannel;
        RACChannelTerminal *defaultsTerminal = [[NSUserDefaults standardUserDefaults] rac_channelTerminalForKey:@"someKey"];
        
        [switchTerminal subscribe:defaultsTerminal];
        [defaultsTerminal subscribe:switchTerminal];
    

    这是一段 RAC 双向绑定的代码,把 UISwitch 和 NSUserDefaults 中的一个字段双向绑定。 我一直琢磨不明白为什么不会出现死循环。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2688 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:29 · PVG 23:29 · LAX 08:29 · JFK 11:29
    ♥ Do have faith in what you're doing.