Set Method not found for 'Text' when using this.Bind on UITextField

155 views
Skip to first unread message

Iván Mejía

unread,
Mar 18, 2015, 10:01:51 PM3/18/15
to reacti...@googlegroups.com
Hi everyone,
  I am testing for the first time RectiveUI (v 6.4.0.1) and I have implemented a simple Login UIViewController. I am not using Xamarin.Forms, all my code is pure iOS API.

This is my ViewController's code:

public partial class LoginViewController : ReactiveViewController, IViewFor<LoginViewModel>
{
public override void ViewDidLoad()
      {
         base.ViewDidLoad();
         // bind UI...
         _viewModel = new LoginViewModel();

         // bind the fields...
         this.Bind(_viewModel, vm => vm.IsValid, lvc => lvc.SignIn.Enabled);
         this.Bind(_viewModel, vm => vm.UserEmailProperty, lvc => lvc.UserEmail.Text);
         this.Bind(_viewModel, vm => vm.PasswordProperty, lvc => lvc.Password.Text);

         Observable.FromEventPattern(x => SignIn.TouchUpInside += x, x => SignIn.TouchUpInside -= x)
            .Subscribe(args => ViewModel.ExecuteSignIn.Execute(null)); 
      }
}

The properties UserEmail and Password are of type UITextField.

All works fine on the simulator, once I go to the real device I get the error message: 

Set Method not found for 'Text' on the lines shown in bold above, any ideas? 

Thanks for any clue(s),
Ivan.

Iván Mejía

unread,
Mar 19, 2015, 10:44:51 AM3/19/15
to reacti...@googlegroups.com
In case someone else find the same problem, this is the way I worked around it, instead of using this.Bind as in the bold lines shown on my previous post I replace those using directly the LINQ approach passing an Observable an then subscribing to the data stream, like this:

var resUE = from evt in Observable.FromEventPattern(x => UserEmail.EditingChanged += x, x => UserEmail.EditingChanged -= x)
               select ((UITextField)evt.Sender).Text;
resUE.Subscribe(s => ViewModel.UserEmailProperty = s);

var resP = from evt in Observable.FromEventPattern(x => Password.EditingChanged += x, x => Password.EditingChanged -= x)
              select ((UITextField)evt.Sender).Text;
resP.Subscribe(s => ViewModel.PasswordProperty = s);
Reply all
Reply to author
Forward
0 new messages