NSMutableArray check if object already exists

前端 未结 9 1455
傲寒
傲寒 2020-12-25 10:17

I am not sure how to go about this. I have an NSMutableArray (addList) which holds all the items to be added to my datasource NSMutableArray.

I now

9条回答
  •  不知归路
    2020-12-25 10:55

    I found a solution, may not be the most efficient of all, but atleast works

    NSMutableArray *add=[[NSMutableArray alloc]init];
    
    for (Item *item in addList){
            if ([appDelegate.list containsObject:item])
                {}
            else
                [add addObject:item];
    }
    

    Then I iterate over the add array and insert items.

提交回复
热议问题