Decrease values ​​from RACTuple without knowing the number of arguments

I have an IBOutletCollection (TextFields). I can collect all rac_textSignals dynamically, but now I want to reduce the values ​​of these signals, not knowing how many arguments RacTuple will have (the collection of output data may vary).

NSMutableArray *signals = [@[] mutableCopy];

[self.textFields enumerateObjectsUsingBlock:^(UITextField *textField, NSUInteger idx, BOOL *stop) {
    [signals addObject:textField.rac_textSignal];
}];
RACSignal *signal = [RACSignal combineLatest:signals];

How to do it? I cannot find the path using the combLatest: reduce or reduceEach: method.

Thanks in advance.

+4
source share
1 answer

RACTuple is a collection type, so you can simply list it if there is a variable number of values:

[[RACSignal
    combineLatest:signals]
    map:^(RACTuple *strings) {
        for (NSString *string in strings) {
            // Do whatever here.
        }

        return nil;
    }];

There is also a method -allObjectsif you prefer to work with an array.

+3
source

All Articles