Access static variables within class in Swift

后端 未结 7 2183
独厮守ぢ
独厮守ぢ 2020-12-08 09:24

Is ClassName.staticVaribale the only way to access static variable within the class? I want something like self, but for class. Like class.st

7条回答
  •  情歌与酒
    2020-12-08 09:49

    This is solved elegantly in Swift 5.1 you can access it via

    Self.yourConstant
    

    Reference: https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md

提交回复
热议问题