Overriding a stored property in Swift

前端 未结 10 805
鱼传尺愫
鱼传尺愫 2020-11-30 00:10

I noticed that the compiler won\'t let me override a stored property with another stored value (which seems odd):

class Jedi {
    var lightSaberColor = \"Bl         


        
10条回答
  •  孤独总比滥情好
    2020-11-30 00:49

    For Swift 4, from Apple's documentation:

    You can override an inherited instance or type property to provide your own custom getter and setter for that property, or to add property observers to enable the overriding property to observe when the underlying property value changes.

提交回复
热议问题