Hi, I'm a little confused with retain counts and properties. I would appreciate some help in understanding this. I have a class setup as follows
@interface Cell : NSObject { NSImage *image; } @property (copy) NSImage *image; @end Now, in my code, I do the following NSImage *img = [[NSImage alloc] init]; Cell *cell = [[Cell alloc] init]; [cell setImage:img]; NSLog(@"Original image pointer: %x, retain count: %d", img,[img retainCount ]); NSLog(@"Cell image pointer: %x, retain count: %d", cell.image, [cell.image retainCount]); NSLog(@"Cell image pointer: %x, retain count: %d", [cell image], [[cell image] retainCount]); It looks like everytime I call [cell image] the retain count goes up. Why would this be the case? It doesn't matter if I set the property to copy or retain, I see the same results. Am I expected to do the following NSImage *img = [cell image]; NSLog(@"Cell image pointer: %x, retain count: %d", [image retainCount]); I guess my question is do getters automatically increment the retain count instead of my having to do [[cell image] retain]? Thanks Regards George M.P. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com