Swift设置只读(readOnly)属性

发布时间:2019-07-17 22:00:16发布者:Mr.Zhang阅读(320)

class ReadOnly {
private(set) var name: String

init(_ name: String) {
    self.name = name
}

}

let obj = ReadOnly.init("hah")
//以下代码会报错
obj.name = "hahh"





本文转自博客园,原文地址:https://www.cnblogs.com/flutter-cn/p/11203840.html