如何停止块枚举?
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