在 Objective-C 中,NSIndexSet
可以removeIndexes:(NSIndexSet *)indexSet
:
[aIndexSet removeIndexes: bIndexSet];
有没有什么方法可以像 Objective-C 中的 NSIndexSet
那样在 Swift 中使用 IndexSet
来做到这一点?
最佳答案
有一个函数,来自documentation
mutating func subtract(_ other: IndexSet)
Removes the elements of the given set from this set.
var aIndexSet = IndexSet(integersIn: 0..<7)
let bIndexSet = IndexSet(integersIn: 4..<12)
aIndexSet.subtract(bIndexSet)
print(aIndexSet) // 0..<3
关于swift - 如何在 Swift 中从 IndexSetB 中删除 IndexSetA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43953857/