Skip to content

Instantly share code, notes, and snippets.

@veeneck
Created June 17, 2014 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veeneck/0aa2c50e08d9f6798e12 to your computer and use it in GitHub Desktop.
Save veeneck/0aa2c50e08d9f6798e12 to your computer and use it in GitHub Desktop.
Swift Static Var
class Flag : SKSpriteNode {
struct FlagSingleton {
static var texture = SKTexture[]()
static var onceToken: dispatch_once_t = 0
}
class func loadSharedAssets() {
dispatch_once(&FlagSingleton.onceToken, {
FlagSingleton.textures.append(SKTexture(imageNamed:"flag_castle"))
FlagSingleton.textures.append(SKTexture(imageNamed:"flag_melee"))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment