【发布时间】:2015-07-12 10:39:23
【问题描述】:
我们有一个具有数组属性的类,该类具有didSet 观察者。然而,当我们在这个数组上调用removeAtIndex 时,似乎调用了didSet 观察者。有什么办法可以阻止这种情况发生?
var items: [String] = []
{
didSet
{
println(self.items.count)
}
}
...
func removeIndex(index: Int)
{
self.items.removeAtIndex(index)
// now didSet is called, but we don't want that
}
【问题讨论】:
标签: ios arrays swift properties