NSLog(@"++++%@",[self seprateBigArrBySize:3 BigArr:@[@"1",@"2",@"3",@"4",@"5",@"6",@"7"]]);
打印结果:@[@[@"1",@"2",@"3"],@[@"4",@"5",@"6"],@[@"7"]];
-(NSArray *)seprateBigArrBySize:(int)size BigArr:(NSArray*)bigArr{
NSMutableArray * temp = [NSMutableArray array];
int start,end = 0;
double newSize = size;
NSLog(@"-----%f++++%zd",ceil(bigArr.count/newSize),lrint(ceil(bigArr.count/newSize)));
for (int i = 0; i < lrint(ceil(bigArr.count/newSize)); i++) {
start = i* size;
end = start + size;
if (end > bigArr.count) {
size = bigArr.count%size;
}
[temp addObject:[bigArr subarrayWithRange:NSMakeRange(start, size)]];
}
return temp.copy;
}