Computed Properties vs Property Requirements - protocol

In addition to stored properties, classes, structures, and enumerations can define computed properties, which do not actually store a value. Instead, they provide a getter and an optional setter to retrieve and set other properties and values indirectly.

 

A protocol can require any conforming type to provide an instance property or type property with a particular name and type. The protocol doesn’t specify whether the property should be a stored property or a computed property—it only specifies the required property name and type. The protocol also specifies whether each property must be gettable or gettable and settable.

 

https://docs.swift.org/swift-book/LanguageGuide/Properties.html

 
posted @ 2018-09-13 19:30  zzfx  阅读(156)  评论(0编辑  收藏  举报