Search code examples
swiftscenekitenumeratescnnode

enumerateChildNodesUsingBlock(), setting stop to true


I am attempting to use enumerateChildNodesUsingBlock() where I set stop to true so the enumeration will ignore child nodes. There is a similar question: How to use "enumerateChildNodesWithName" with Swift in SpriteKit? But nothing I try sets stop to true. Maybe something different is needed in Swift 2.0?

EDIT: I found a video relating to a similar enumeration. Evidently stop.memory = true belongs further along in the body of the closure as opposed to modifing the first use of stop.


Solution

  • I'm not a user of SpriteKit, so I may be wrong here, but if stop is an UnsafeMutablePointer<ObjCBool> object, you can set its value like this:

    stop[0] = true
    

    inside the closure to stop the enumeration.

    I believe it should also work with

    stop.memory = true
    

    but for some reason this doesn't work for me when testing with different but similar methods (enumerateSubstringsInRange for example).