Home  >  Q&A  >  body text

ios - ReactiveCocoa5.0 绑定问题

我想将UITextField的里面的text直接绑定到ViewModel的username属性上。但是怎么都不行

viewModel.username <~ usernameTextField.reactive.textValues

username是String类型。<~ 的左右两边类型不对,但是我试了很多属性了,都不行,请问一下问题在哪里啊?

怪我咯怪我咯2765 days ago430

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:57:14

    username should be a property in RAC
    such as:

        var username: MutableProperty<String?> = MutableProperty<String?>(nil)
        //some code
        username <~ usernameTextField.reactive.textValues

    That’s it
    For the value binding of RAC5, you can read the official documentation: https://github.com/ReactiveCo...

    reply
    0
  • Cancelreply