holy_sin
V2EX  ›  问与答

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

  •  1
     
  •   holy_sin · May 5, 2016 · 3220 views
    This topic created in 3687 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   ·   5907 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 02:40 · PVG 10:40 · LAX 19:40 · JFK 22:40
    ♥ Do have faith in what you're doing.