swift是否有类级别的静态variables?

如何在类作用域中声明静态常量? 如

class let Constant: Double = 3.1415926 // I know that in class we use class modifier instead of static. 

从Swift 1.2开始,Swift支持静态types的属性,包括类:

 class MyClass { static let pi = 3.1415926 } 

如果您需要在子类中有可覆盖的类variables,则需要使用计算的类属性:

 class MyClass { class var pi: Double { return 3.1415926 } } class IndianaClass : MyClass { override class var pi: Double { return 4 / (5 / 4) } }