Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created July 7, 2017 08:53
Show Gist options
  • Save SunXiaoShan/a5117ff11f4b825280f3071951af8101 to your computer and use it in GitHub Desktop.
Save SunXiaoShan/a5117ff11f4b825280f3071951af8101 to your computer and use it in GitHub Desktop.
RAC_array_example
// loop all element
NSArray *array = @[@"1", @"2", @"3", @"4", @"5"];
[array.rac_sequence.signal subscribeNext:^(id _Nullable x) {
NSLog(@"element:%@", x);
}];
// output
// element:1
// element:2
// element:3
// element:4
// element:5
NSArray *array2 = @[@1, @2, @3, @4, @5];
[[array2.rac_sequence.signal filter:^BOOL(id _Nullable value) {
return [value integerValue] > 2;
}]
subscribeNext:^(id _Nullable x) {
NSLog(@"element 2:%@", x);
}];
// output
// element 2:3
// element 2:4
// element 2:5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment