I would like to verify something that I always use but when I think about it ... I get confused why it worked that way and I sure I read the explanation about it but I cant find it. As far as I understand apple create their setter as something like this.
-(void)setString:(NSString *)value {
if (_string != value) {
[_string release];
_string = [value retain];
}
}
Now usually I create properties like this.
@property (nonatomic) NSString *string;
@synthesize string = _string;
The question is about next code:
NSString *s = @"Should be deleted";
[self setString:s];
NSLog(@"string check111 =%@",self.string);
s = NULL;
NSLog(@"string check222=%@",self.string);
The same output will be generated. From the setter I can see that my property points on the object that I changed but the property value will be the same.That situation triggers another question (if it works like that why would I need copy attribute). Can someone provide a short explanation about it? (or concrete link to read). Tnx A Lot. (I think my question may be already asked in the forum )