How to stop enumerateObjectsUsingBlock Swift

后端 未结 5 514
慢半拍i
慢半拍i 2020-12-14 15:26

How do I stop a block enumeration?

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


        
5条回答
  •  轮回少年
    2020-12-14 16:21

    This has unfortunately changed every major version of Swift. Here's a breakdown:

    Swift 1

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

    Swift 2

    stop.memory = true
    

    Swift 3

    stop.pointee = true
    

提交回复
热议问题