Class 类型属性不应该有 static 关键字?

Class type properties should not have static keyword?

  1. 这是 Apple 文档示例中的图片,为什么前 2 个属性有 'static' 关键字??我认为静态应该只用于结构和枚举?

  2. 其次,为什么这个class有一个存储类型属性?我以为 classes 只能计算类型属性???

  1. 有效 Swift 1.2,现在 类 允许 static 属性。

  2. 类 一直被允许存储属性。

来自Xcode 6.3 (Swift 1.2) release notes, under Swift Language Enhancements

static methods and properties are now allowed in classes (as an alias for class final).

You are now allowed to declare static stored properties in classes, which have global storage and are lazily initialized on first access (like global variables).