小编典典

如何停止enumerateObjectsUsingBlock Swift

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;
    }];

阅读 440

收藏
2020-07-07

共1个答案

小编典典

在Swift 1中:

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

在Swift 2中:

stop.memory = true

在Swift 3-4中:

stop.pointee = true
2020-07-07