setter and getter for an atomic property setter and getter for an atomic property objective-c objective-c

setter and getter for an atomic property


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.


if you do not specify the readonly with property declaration then Compiler will produce the getter and setter and be as below.

setter  ---> setValue:[self setValue:@"setter"];getter -----> Value,NSString* myValue =  [self Value];

Compilar will not produce the setter function for the property which you have declared with readonly.

atomic are thread safe whereas nonatomic is not.