swift中的只读属性实现,很简单

原文地址readonly properties in Swift

Turns out just like in Obj-C, in Swift it's possible to declare nicely encapsulated readonly properties.

public private(set) var foo: String

Thank you NSHipster reader Stephen Celis

原来这么简单,但好像很少人说

你可能感兴趣的:(swift中的只读属性实现,很简单)