开发者

Remove elements from one NSMutableArray which are contained in another array

开发者 https://www.devze.com 2023-01-28 20:53 出处:网络
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 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消