如何检查另一个数组中不存在的数组值 [英] How to check array value not exist in another array
本文介绍了如何检查另一个数组中不存在的数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个不同的NSMutabelArray ArrOne和ArrTwo。 Letsay ArrOne = A,B,C和D ArrTwo = C,D,X和Y.所以我需要检查ArrTwo的值是否与ArrOne相同,如果它与ArrOne中的不相同,则从ArrTwo中删除项目。在这种情况下,我必须从ArrTwo中删除X和Y.请给我一个主意。
I have two different NSMutabelArray ArrOne and ArrTwo. Letsay ArrOne = A, B, C and D ArrTwo = C, D, X and Y. So i need to check if the value of ArrTwo is same as ArrOne and remove item from ArrTwo if it is not same as in ArrOne. In this case, i have to remove X and Y from ArrTwo. Please give me an idea.
推荐答案
我找到了一个解决方案并且有效
I found a solution and it works
for (int i=0; i< arrTwo.count; i++)
{
if(![arrOne containsObject:[arrTwo objectAtIndex:i]])
{
//do action
NSLog(@"do delete %@",[arrTwo objectAtIndex:i]);
}
}
谢谢!
这篇关于如何检查另一个数组中不存在的数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文