如何停止区 block 枚举?
myArray.enumerateObjectsUsingBlock( { object, index, stop in
//how do I stop the enumeration in here??
})
我知道在 obj-c 中你这样做:
[myArray enumerateObjectsUsingBlock:^(id *myObject, NSUInteger idx, BOOL *stop) {
*stop = YES;
}];
最佳答案
不幸的是,这改变了 Swift 的每个主要版本。这是一个分割:
swift 1
stop.withUnsafePointer { p in p.memory = true }
swift 2
stop.memory = true
swift 3
stop.pointee = true
关于objective-c - 如何停止 enumerateObjectsUsingBlock Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24214136/