Swift Nil Check

Useful Nil Name Check

// verify name not nil
if ((node.name?.isEmpty) != nil) {
// exclude already clicked items
// only player circle
if node.name == "player" {
// change node position
node.position = location

//turn off player gravity field
let player = childNodeWithName("player") as! SKShapeNode
player.physicsBody?.dynamic = false
player.physicsBody!.fieldBitMask = PhysicsCategory.player
player.physicsBody?.dynamic = true
}
}