self.list = @[@"1", @"2", @"3", @"4", @"5", @"6", @"3"];
[self.list bk_each:^(id obj) {
NSLog(@"bk_each: %@", obj);
}];
NSArray *bk_map = [self.list bk_map:^id(id obj) {
return [NSString stringWithFormat:@"%@.png", obj];
}];
NSLog(@"%@", bk_map);
NSString *bk_reduceStr = [self.list bk_reduce:@"A" withBlock:^id(id sum, id obj) {
return [sum stringByAppendingString:obj];
}];
NSLog(@"bk_reduceStr: %@", bk_reduceStr);
NSInteger bk_reduceInteger = [self.list bk_reduceInteger:2 withBlock:^NSInteger(NSInteger result, id obj) {
return result + [obj integerValue];
}];
NSLog(@"bk_reduceInteger: %ld", bk_reduceInteger);
NSLog(@"bk_any: %d", [self.list bk_any:^BOOL(id obj) {
return [obj isEqualToString:@"7"];
}]);
[self.list bk_apply:^(id obj) {
NSLog(@"bk_apply: %@", obj);
}];
NSLog(@"bk_any: %d", [self.list bk_any:^BOOL(id obj) {
return [obj isEqualToString:@"4"];
}]);
NSLog(@"bk_none: %d", [self.list bk_none:^BOOL(id obj) {
return [obj isEqualToString:@"4"];
}]);
NSLog(@"bk_all: %d", [self.list bk_all:^BOOL(id obj) {
return [obj isEqualToString:@"4"];
}]);
NSArray *arr1 = @[@"1", @"2", @"3", @"4", @"5", @"6", @"3"];
NSArray *arr2 = @[@"1", @"2", @"3", @"4", @"5", @"6", @"4"];
NSLog(@"%d", [self.list bk_corresponds:arr1 withBlock:^BOOL(id obj1, id obj2) {
return [obj1 isEqual:obj2];
}]);
NSLog(@"%d", [self.list bk_corresponds:arr2 withBlock:^BOOL(id obj1, id obj2) {
return [obj1 isEqual:obj2];
}]);
NSArray *selArr = [self.list bk_select:^BOOL(id obj) {
return [obj isEqualToString:@"3"];
}];
NSLog(@"bk_select: %@", selArr);
NSString *bk_match = [self.list bk_match:^BOOL(id obj) {
return [obj isEqualToString:@"3"];
}];
NSLog(@"bk_match: %@", bk_match);
NSArray *bk_reject = [self.list bk_reject:^BOOL(id obj) {
return [obj isEqualToString:@"3"];
}];
NSLog(@"bk_reject: %@", bk_reject);
网友评论