V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
holy_sin
V2EX  ›  问与答

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

  •  1
     
  •   holy_sin · May 5, 2016 · 3133 views
    This topic created in 3647 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   ·   836 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.