根據數組中某個屬性值 去除相同的元素

 

    NSMutableSet *set = [NSMutableSet set];

    NSPredicate * red = [NSPredicate predicateWithBlock: ^BOOL(id obj, NSDictionary *bind) {

        BLEModel *Obj = (BLEModel*)obj;

        BOOL seen = [set containsObject:Obj.adString];

        if (!seen) {

            [set addObject:Obj.adString];

        }

        return !seen;

    }];

    

    self.section0List = [NSMutableArray arrayWithArray:[[set allObjects] filteredArrayUsingPredicate: red]];



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章