初次看到這個函數(shù)時候膳汪,疑惑reduce的意思框沟。查字典發(fā)現(xiàn)reduce除了“減少”的意思還有“簡化”的意思雇毫。之前的疑惑終于釋然。
RACSignal *formValid = [RACSignal combineLatest:
@[ self.username.rac_textSignal,
self.emailField.rac_textSignal,
self.passwordField.rac_textSignal,
self.passwordVerificationField.rac_textSignal ]
reduce:^(NSString *username, NSString *email, NSString *password, NSString *passwordVerification) {
return @([username length] > 0 && [email length] > 0 &&
[password length] > 8 &&
[password isEqual:passwordVerification]);
}];
RAC(self.createButton.enabled) = formValid;