我在myArray中有这种模式:
myArray[0][0] = "28.04"
myArray[1][0] = "21.12"
myArray[2][0] = "12.33"
我想要这样:
myArray[0] = "28.04"
myArray[1] = "21.12"
myArray[2] = "12.33"
答案 0 :(得分:-1)
您需要一个名为flatmap的高阶函数
- (NSArray *)flatMap:(id (^)(id obj))block {
NSMutableArray *mutableArray = [NSMutableArray new];
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
id _obj = block(obj);
if ([_obj isKindOfClass:[NSArray class]]) {
NSArray *_array = [_obj flatMap:block];
[mutableArray addObjectsFromArray:_array];
return;
}
[mutableArray addObject:_obj];
}];
return mutableArray;
}