通过Dictionary我们可以将模型数据放到一个字典里, Id作为 Key 这样出现重复的Id 可以将原来的值进行重新赋值,因为字典里 key 是唯一的
NSMutableDictionary *tempDict = [NSMutableDictionary dictionary];
for(GoodsCouponListModel *model in tempArray){
[tempDict setObject:model forKey:model.uuid];
}
tempArray = [[tempDict allValues] mutableCopy];
网友评论