Search code examples
swiftswift-array

Remove objects from NsMutableArray with removeObjectsInArray(someArray) in swift


I have two NSMutableArray's
I am trying to remove the MutableArray from other Array with removeObjectsInArray() method
Here is my code:

arrayImage.removeObjectsInArray(arrayDeleteImage)


But it requires a filter (NSPredicate), I don't understand why it's requried..
I have implement the filter but it's giving me an error..

 arrayImage = arrayImage.filter //error:Nsmutable does not have member filter
    { value in
        !contains(arrayDeleteImage, value) //Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
    }


How can I remove the array objects from the other array ?


Solution

  • Try this:

    var arrayOne:[NSMutableArray]
    var arrayTwo:[NSMutableArray]
    
    for ar in arrayTwo
    {
             arrayOne.removeObject(ar)
    }