一维数组变二维数组

```

NSMutableArray *dateMutablearray = [NSMutableArray array];

NSArray *array1 = @[@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-01",@"2014-04-02",@"2014-04-03",

@"2014-04-04",@"2014-04-06",@"2014-04-08",

@"2014-04-05",@"2014-04-07",@"2014-04-09",];

NSMutableArray *array = [NSMutableArray arrayWithArray:array1];

for (int i = 0; i < array.count; i ++) {

NSString *string = array[i];

NSMutableArray *tempArray = [NSMutableArray array];

[tempArray addObject:string];

for (int j = i+1; j < array.count; j ++) {

NSString *jstring = array[j];

if([string isEqualToString:jstring]){

[tempArray addObject:jstring];

[array removeObjectAtIndex:j];

j=j-1;

}

}

[dateMutablearray addObject:tempArray];

}

NSLog(@"array:%@",array);

NSLog(@"dateMutable:%@",dateMutablearray);

```

你可能感兴趣的:(一维数组变二维数组)