Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save veeneck/5eafa5e3170b65b326c5 to your computer and use it in GitHub Desktop.

Select an option

Save veeneck/5eafa5e3170b65b326c5 to your computer and use it in GitHub Desktop.
Swift Casting in Callback Parameter
// How do you cast SKNode to Flag : SKNode in parameter definition?
scene.enumerateChildNodesWithName("flag") {
node as Flag, stop in
node.methodAvailableToFlagObject()
}
// I'm trying to avoid having to do this:
scene.enumerateChildNodesWithName("flag") {
node, stop in
let realNode = node as Flag
realNode.methodAvailableToFlagObject()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment