2018-07-28 iOS 遍历数组,提取相同元素存入另外一个数组

NSArray *array1 = @[@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-01",@"2016-10-02",@"2016-10-03",

@"2016-10-04",@"2016-10-06",@"2016-10-08",

@"2016-10-05",@"2016-10-07",@"2016-10-09"];

NSMutableArray *array= [NSMutableArray arrayWithArray:array1];

    NSMutableArray *dateMutablearray = [@[] mutableCopy];

for(inti =0; i

NSString *string=array[i];

        NSMutableArray *tempArray = [@[] mutableCopy];

[tempArray addObject:string];

for(intj = i+1; j

NSString *jstring =array[j];

if([stringisEqualToString:jstring]){

                [tempArray addObject:jstring];

[arrayremoveObjectAtIndex:j];

j -=1;

            }

        }

        [dateMutablearray addObject:tempArray];

    }

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

你可能感兴趣的:(2018-07-28 iOS 遍历数组,提取相同元素存入另外一个数组)