How to remove single object in array from multiple matching object

后端 未结 2 657
一整个雨季
一整个雨季 2021-01-22 14:05
var testarray = NSArray() 
testarray = [1,2,2,3,4,5,3] 
print(testarray) 
testarray.removeObject(2)

I want to remove single object from multiple matchi

2条回答
  •  -上瘾入骨i
    2021-01-22 14:56

    If you want to remove all duplicate objects then you can use below code.

        var testarray = NSArray()
        testarray = [1,2,2,3,4,5,3]
    
        let set = NSSet(array: testarray as [AnyObject])
        print(set.allObjects)
    

提交回复
热议问题