我怎样才能实现这个目标
必须为类
对于与类
答案 0 :(得分:1)
@interface MyObject : NSObject
@property (nonatomic, readonly, strong) NSString *myProperty;
@end
// Class extension
@interface MyObject ()
// Redeclare property read-write
@property (nonatomic, readwrite, strong) NSString *myProperty;
@end
@implementation MyObject
...
class MyObject {
private(set) var myProperty: String
...
答案 1 :(得分:1)
尝试以下示例
在你的.h:
@property(nonatomic, retain, readonly) NSDate* theDate;
在你的.m:
@interface TheClassName()
@property(nonatomic, retain, readwrite) NSDate* theDate;
@end