Remove elements from one NSMutableArray which are contained in another array

你。 提交于 2019-12-01 15:57:50

问题


I have two arrays, A and B.

How can I remove elements from A, if those elements exist in B?

e.g. Array A:{1,2,3,4,5}, array B:{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?


回答1:


You have the removeObjectsInArray: method from NSMutableArray. It does what you want.



来源:https://stackoverflow.com/questions/4365323/remove-elements-from-one-nsmutablearray-which-are-contained-in-another-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!