我在 View 中添加了一个 UIButton
。我的观点也有三个文本框即。 用户名、密码和确认密码。基于这些文本框的合法内容,我需要启用我的注册按钮。
这是我的代码片段:-
UIButton *signUp = [[UIButton alloc]initWithFrame:CGRectMake(10, 100, 50, 20)];
signUp.backgroundColor = [UIColor greenColor];
signUp.enabled = NO ;
[self.view addSubview:signUp];
RACSignal *formValid = [RACSignal
combineLatest:@[
username.rac_textSignal,
password.rac_textSignal,
confirmPassword.rac_textSignal
]
reduce:^(NSString *username, NSString *password, NSString *passwordVerification) {
return @([username length] > 0 && [password length] > 8 && [password isEqual:passwordVerification]);
}];
RAC(signUp.enabled) = formValid; //Error is here
在最后一行,我遇到了两个错误:-
- ARC 不允许将“BOOL”(又名“signed char”)隐式转换为“id”
- 预期标识符
我是 Reactive Cocoa 的新手。请忽略错误。
最佳答案
使用 RAC(signUp, enabled)
而不是 RAC(signUp.enabled)
。 RAC
宏至少有两个参数,对象和您要绑定(bind)的键路径。
关于ios - 使用 Reactive Cocoa RACSignal 启用 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20266886/