如何停止enumerateObjectsUsingBlock Swift
如何停止块枚举?
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 1中:
stop.withUnsafePointer { p in p.memory = true }
在Swift 2中:
stop.memory = true
在Swift 3-4中:
stop.pointee = true
以上是 如何停止enumerateObjectsUsingBlock Swift 的全部内容, 来源链接: utcz.com/qa/400919.html