关于iOS去除数组中重新数据的三种艺术

器材:佳能6D+2470

“2014-04-06”,

NSArray *dataArray = @[@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

出镜:@模特–柳柳

“2014-04-09”

dataArray = [dataArray
valueForKeyPath:@”@distinctUnionOfObjects.self”];

必发365.com 1必发365.com 2必发365.com 3必发365.com 4必发365.com 5必发365.com 6

http://blog.csdn.net/wm9028/article/details/49926535

“2014-04-02”,

花季II-【9891image】-1700415

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-01”,

摄影/后期:@9891影像-小包

)

NSSet *set = [NSSet setWithArray:dataArray];

场地:陶然亭

“2014-04-01”,

NSArray *dataArray = @[@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-06”,

@”2014-04-05″,@”2014-04-07″,@”2014-04-09″,];

for(NSString *str in dataArray)

)

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-06”,

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-07”,

其二种办法,利用数组的containsObject来去除

@”2014-04-04″,@”2014-04-06″,@”2014-04-08″,

“2014-04-03”,

“2014-04-07”,

“2014-04-02”,

“2014-04-01”,

“2014-04-05”,

“2014-04-09”

在干活工程中我们不用要会遭受,在数组中有再次数据的时候,怎么样去除重复的多寡吧?

for (NSString *str in dataArray) {

NSMutableArray *listAry = [[NSMutableArray alloc]init];

)

if (![listAry containsObject:str]) {

NSMutableDictionary *dic = [[NSMutableDictionary
alloc]initWithCapacity:0];

NSMutableDictionary *dic = [[NSMutableDictionary
alloc]initWithCapacity:0];

[listAry addObject:str];

(

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

NSLog(@”%@”,dataArray);

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

代码如下:

@”2014-04-05″,@”2014-04-07″,@”2014-04-09″,];

“2014-04-05”,

​for (unsigned i = 0; i < [array count]; i++) {

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-03”,

NSArray *dataArray = @[@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

​}

(

@”2014-04-05″,@”2014-04-07″,@”2014-04-09″,];

打字与印刷结果:

代码如下:

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

​if ([categoryArray containsObject:[array objectAtIndex:i] == NO) {

NSArray *dataArray = @[必发365.com,@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

其二种方式,利用数组的containsObject来去除

}

)

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

打字与印刷结果:

NSArray *dataArray = @[@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

[listAry addObject:str];

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-06”,

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-09”,

“2014-04-05”,

@”2014-04-01″,@”2014-04-03″,@”2014-04-03″,

“2014-04-07”,

NSArray *dataArray = @[@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

@”2014-04-01″,@”2014-04-03″,@”2014-04-03″,

@”2014-04-01″,@”2014-04-02″,@”2014-04-03″,

“2014-04-03”

“2014-04-07”,

“2014-04-07”,

​NSMutableArray *categoryArray = [NSMutableArray alloc] init];

Post Author: admin

发表评论

电子邮件地址不会被公开。 必填项已用*标注