- NSMutableArray *arr = [[NSMutableArray alloc] init];
- for (int i = 0; i < 15 ; i++) {
- [arr addObject:[NSString stringWithFormat:@"damo%d",i]];
- }
- NSLog(@"%@",arr);
- NSMutableArray *bigArr = [[NSMutableArray alloc] initWithCapacity:1];
- NSMutableArray *smallArr = nil;
- for (int i = 0; i < [arr count]; i++) {
- if (i % 3 == 0) {
- //只要读到0 3 6 9 12 就开辟空间存储接下来的三个元素
- smallArr = [[NSMutableArray alloc] initWithCapacity:1];
- //将小数组添加到大数组中进行管理
- [bigArr addObject:smallArr];
- }
- [smallArr addObject:[arr objectAtIndex:i]];
- }
- NSLog(@"%@",bigArr);</span>