What is a Swift array equivalent to NSMutableArray
\'s -removeObjectsAtIndexes:
? Removing each index one by one doesn\'t work, as remaining indexes
I ended up doing it this way:
According to Apple's documentation on NSIndexSet, "index sets store indexes as sorted ranges". So we could enumerate over the given NSIndexSet
backwards and remove the element from the array at each index one by one, like so:
extension Array {
mutating func removeAtIndexes(indexes: NSIndexSet) {
for var i = indexes.lastIndex; i != NSNotFound; i = indexes.indexLessThanIndex(i) {
self.removeAtIndex(i)
}
}
}