Need clarification for Swift Type Properties

后端 未结 1 999
借酒劲吻你
借酒劲吻你 2021-01-28 09:04

Apple\'s swift documentation on Type Properties states:

\"For value types (that is, structures and enumerations), you can define stored and computed type properties. For

相关标签:
1条回答
  • 2021-01-28 09:33

    In your example, the stored property in the class is a static property. But you'll notice there's no stored property in the class that is a class property; that's what's unsupported:

    class SomeClass {
      static var storedTypeProperty = "Some value."
      static var computedTypeProperty: Int {
       // return an Int value here
      }
      // class var overrideableStoredTypeProperty = "Some value." // NO
      class var overrideableComputedTypeProperty: Int {
      // return an Int value here
      }
    }
    
    0 讨论(0)
提交回复
热议问题