美文网首页
iOS 模型数组去重

iOS 模型数组去重

作者: 不辣先生 | 来源:发表于2018-04-16 17:23 被阅读23次

    iOS 模型数组去重

    Tip:不要对一个可变数组遍历的同时增删改查!!!!

    NSMutableArray *temp = [NSMutableArray arrayWithArray:tempArr.copy];
    for (NSInteger i = 0; i < temp.count; i++) {
    for (NSInteger j = i+1;j < temp.count; j++) {
    ItemModel *tempModel = temp[i];
    ItemModel *model = temp[j];
    if ([tempModel compareWithAnotherModel:model]) {
    [tempArr removeObject:model];
    }
    }
    }

    相关文章

      网友评论

          本文标题:iOS 模型数组去重

          本文链接:https://www.haomeiwen.com/subject/zmvekftx.html