iOS中的只读属性

swift

public private(set) var someKey: String

当外部调用set方法时的报错信息:

text

Cannot assign to property: 'somekey' setter is inaccessible

OC表示只读readonly:

Objective-C

@property (nonatomic, strong, readonly) NSString *someKey;