我不知道该怎么办.我有一个NSMutableArray(addList),其中包含要添加到数据源NSMutableArray的所有项.
现在我想判断数据源数组中是否已经存在要从addList数组添加的对象.如果不存在,则添加该项;如果存在,则忽略该项.
这两个对象都有一个名为iName的字符串变量,我想对其进行比较.
这是我的代码片段
-(void)doneClicked{
for (Item *item in addList){
/*
Here i want to loop through the datasource array
*/
for(Item *existingItem in appDelegate.list){
if([existingItem.iName isEqualToString:item.iName]){
// Do not add
}
else{
[appDelegate insertItem:item];
}
}
}
但我发现即使它存在也要添加.
我做错了什么?