Objective-C的 - 如何比较阵列和提取的区别? [英] Objective-C - How to compare arrays and extract the difference?
本文介绍了Objective-C的 - 如何比较阵列和提取的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的复制:<一href=\"http://stackoverflow.com/questions/1475636/comparing-two-arrays/1475656#1475656\">comparing-two-arrays
块引用>我有两个NSArray的,我想从第二阵列创建对象的新阵,但不
包括在第一阵列中的示例:NSMutableArray里* firstArray = [NSMutableArray的arrayWithObjects:@条例,@奔,@克里斯,@梅利莎零]
NSMutableArray里* secondArray = [NSMutableArray的arrayWithObjects:@条例,@保罗零]由此产生的阵列应该是:[@保罗零]我解决了这个问题,以双循环比较对象到内部之一。
有没有更好的办法呢?
解决方案[secondArray removeObjectsInArray:firstArray];
这个想法是从另一个答案。
Possible duplicate: comparing-two-arrays
I have two NSArray and I'd like to create a new Array with objects from the second array but not included in the first array.
Example: NSMutableArray *firstArray = [NSMutableArray arrayWithObjects:@"Bill", @"Ben", @"Chris", @"Melissa", nil]; NSMutableArray *secondArray = [NSMutableArray arrayWithObjects:@"Bill", @"Paul", nil]; The resulting array should be: [@"Paul", nil];
I solved this problem with a double loop comparing objects into the inner one.
Is there a better solutions ?
解决方案[secondArray removeObjectsInArray:firstArray];
This idea was taken from another answer.
这篇关于Objective-C的 - 如何比较阵列和提取的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文