Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Releasing @property(copy) instance variables?

I am pretty sure I am doing this right, but just wanted to check. I have two instance variables that have accessors created via @property. In my dealloc (for the same object) I am releasing these objects.

@property(copy) NSString *firName;
@property(copy) NSString *surName;

-(void)dealloc {
    NSLog(@"_deal: %@", self);
    [firName release];
    [surName release];
    [super dealloc];
}

gary

like image 310
fuzzygoat Avatar asked Nov 30 '09 15:11

fuzzygoat


1 Answers

Yes, that's correct.

The implementation of the property will call release on the previous value before copying the new value, so the only memory management you have to worry about is releasing in the dealloc method, which you're doing.

like image 164
Ben S Avatar answered Nov 17 '22 13:11

Ben S