Swift设置只读(readOnly)属性

class ReadOnly {
private(set) var name: String

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

}

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

posted @ 2019-07-17 21:35  FlutterStudy  阅读(4049)  评论(0编辑  收藏  举报