What does this mean? Variable declared followed by a block without assignment

前端 未结 3 1959
梦毁少年i
梦毁少年i 2021-01-25 12:54

Noob Swift question--I can\'t figure out what this means in Swift:

public var currentTime: NSTimeInterval? {
    return self.audioPlayer?.currentTime
}
         


        
3条回答
  •  天涯浪人
    2021-01-25 13:42

    This is called Read-Only Computed Properties

    According to Apple Docs

    A computed property with a getter but no setter is known as a read-only computed property. A read-only computed property always returns a value, and can be accessed through dot syntax, but cannot be set to a different value.

    For more info Computed Properties

提交回复
热议问题