从一个NSMutableArray中删除包含在另一个数组中的元素 [英] Remove elements from one NSMutableArray which are contained in another array
本文介绍了从一个NSMutableArray中删除包含在另一个数组中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个数组,A和B.
I have two arrays, A and B.
如果B中存在元素,如何从A中删除元素?
How can I remove elements from A, if those elements exist in B?
例如数组A:{1,2,3,4,5},数组B:{1,3}
e.g. Array A:{1,2,3,4,5}, array B:{1,3}
我想从数组A中删除1和3
I would like to remove 1 and 3 from array A such that array A only contains 2,4,5 after the operation.
除了循环之外,还有什么更有效的方法吗?
Besides looping, is there any more efficient approach to doing it?
推荐答案
您从 NSMutableArray
removeObjectsInArray: >。它做你想要的。
You have the removeObjectsInArray:
method from NSMutableArray
. It does what you want.
这篇关于从一个NSMutableArray中删除包含在另一个数组中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文