Prior to ARC, if I wanted a property to be readonly to using it but have it writeable within the class, I could do:
// Public declaration
@interface SomeClass :
Yes, that is adequate, but you don't even need that much.
You can do
- (void)setMyProperty:(NSString *)newValue
{
myProperty = newValue;
}
The compiler will do the right thing here.
The other thing though, is you don't even need THAT. In your class extension you can actually respecify @property
declarations.
@interface SomeClass : NSObject
@property (nonatomic, readonly, strong) NSString *myProperty;
@end
@interface SomeClass()
@property (nonatomic, readwrite, strong) NSString *myProperty;
@end
Doing that, you just need to synthesize and you have a private setter that is synthesized for you.