How can I go about achieving this
Property has to be readwrite for inner implementation in class
Property has to be readonly for external interaction to instances of the class
@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
...
Try like the following example
In your .h:
@property(nonatomic, retain, readonly) NSDate* theDate;
In your .m:
@interface TheClassName()
@property(nonatomic, retain, readwrite) NSDate* theDate;
@end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.