what's the auto-gen'd getter and setter look like for the following property value?
... in .h
@interface MyClass : NSObject {
@private
NSString *_value;
}
@property(retain) NSString *value;
... in .m
@synthesize value = _value;
what if I change the property to be
@property(retain, readonly) NSString *value;
specifically I am interested in the atomic part of the story, plus the retain, and if possible, detailed code would be more clear as to what's going exactly going on behind the scene.
They would look something like:
- (NSString*) value
{
@synchronized(self) {
return [[_value retain] autorelease];
}
}
- (void) setValue:(NSString*)aValue
{
@synchronized(self) {
[aValue retain];
[_value release];
_value = aValue;
}
}
If you change the property to readonly, no setter is generated. The getter will be identical.