ReactiveCocoa学习记录

初次看到这个函数时候,疑惑reduce的意思。查字典发现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;

你可能感兴趣的:(ReactiveCocoa学习记录)