//根据数据源里面的某些属性去掉重复的数据源
NSMutableArray *newGroupArray = [[NSMutableArrayalloc] init];
for(int i=0;i<[groupArraycount];i++ ){
MyItem *item = [groupArray objectAtIndex:i];
if(i==0){
[newGroupArrayaddObject:item];
continue;
}
for(int j=0;j<[newGroupArraycount];j++){
MyItem *item1 = [newGroupArrayobjectAtIndex:j];
if([item.IDisEqualToString:item1.ID])
break;
if(![item.IDisEqualToString:item1.ID]&&j==[newGroupArraycount]-1){
[newGroupArrayaddObject:item];
}
}
}
本文介绍了一种使用Objective-C实现的数据去重方法,通过遍历数据源并对比ID属性来去除重复项,确保集合中每个元素的唯一性。
5522

被折叠的 条评论
为什么被折叠?



