random random -5 years ago 187
Swift Question

How to stop enumerateObjectsUsingBlock Swift

How do I stop a block enumeration?

myArray.enumerateObjectsUsingBlock( { object, index, stop in
//how do I stop the enumeration in here??

I know in obj-c you do this:

[myArray enumerateObjectsUsingBlock:^(id *myObject, NSUInteger idx, BOOL *stop) {
*stop = YES;

Answer Source
stop.withUnsafePointer { p in p.memory = true }

In Swift >= 2

stop.memory = true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download