Use of unresolved type MutableProperty

384 Views Asked by At

I am trying to declare a property in view model that i will later bind to a view..

  class LoginViewModel {

     let myProperty = MutableProperty("")//error here undeclared type MutableProperty

    }

I am using ReactiveCocoa '5.0.0-alpha.3'.

2

There are 2 best solutions below

1
MeXx On BEST ANSWER

Since ReactiveCocoa was split into ReactiveCocoa and ReactiveSwift, you'll probably need to import @import ReactiveSwift in your file as well as @import ReactiveCocoa

Also, if you're adding ReactiveCocoa via Carthage, dont forget to also add the ReactiveSwift.framework to your Project.

6
Shaw On

To monitor the textField/ textView values changed, this code works for me:

passwordTF.reactive.continuousTextValues.observeValues({ print("the new value is \($0!)") })

And the console log like this:

the new value is q
the new value is qw
the new value is qwe
the new value is qwer

There is a other method to monitor the value when the editing is ended:

passwordTF.reactive.textValues.observeValues({ print("the new value is \($0!)") })

And the console log the result in one line:

the new value is qwer