Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    upvoted for the comment of LearnCocos2D :) , also for the style. Commented Oct 14, 2015 at 5:39
  • 2
    the global variable should be changed to a class variable via a static inside the class. Commented Dec 1, 2015 at 5:09
  • 2
    @malhal when a variable is marked private but outside a class, it's not global - but scoped only to the file it is in. A static inside the class would work pretty much the same, but i've updated the answer to use the static as you suggested, as it better groups the variable to the class if you happen to use multiple classes within the file. Commented Dec 2, 2015 at 3:56
  • 1
    "Swift Singletons are exposed in the cocoa frameworks as class functions" ... Not in Swift 3. They're now usually static properties. Commented Sep 22, 2016 at 1:10