对数组的操作:遍历、筛选、映射、替换
1、遍历
NSArray * array = @[@"",@"",@""];
[array.rac_sequence.signal subscribeNext:^(id _Nullable x) {
NSLog(@"数组内容:%@", x);
}];
2、筛选
NSArray *filter = [[array.rac_sequence filter:^BOOL(id value) {
return [value integerValue] > 0 ;
}] array];
NSLog(@"filter:%@",filter);
3、映射
NSArray *map = [[array.rac_sequence map:^id(id value) {
NSInteger a = [value integerValue] * [value integerValue];
return [NSString stringWithFormat:@"%ld", a];
}] array];
4、替换
NSArray * array1 = @[@"1",@"2",@"3"];
NSArray * newArray = [[array1.rac_sequence mapReplace:@"88"] array];