Re: retainCount
Re: retainCount
- Subject: Re: retainCount
- From: "Mike Vannorsdel" <email@hidden>
- Date: Fri, 13 Jul 2001 17:26:41 -0600
On Friday, July 13, 2001, at 05:09 PM, Markus Hitter wrote:
@implementation Worker
[...]
NSString *intImageName;
[...]
- (void)awakeFromNib {
intImageName = [[NSString alloc] initWithString:@"temp-image-"];
Beware here, this is a leak. You allocated an NSString object, then
changed the pointer below to another object without releasing the
first. Change the above line to :
intImageName = [NSString stringWithString:@"temp-image-"];
to avoid the leak by adding the object to the autorelease pool.
intImageName = [intImageName stringByAppendingString:NSUserName()];
NSLog(@"intImageName's retain count is: %d", [intImageName
retainCount]);
[...]
To make this work, do:
NSLog([NSString stringWithFormat:@"intImageName's retain count is: %d",
[intImageName retainCount]]);
References: | |
| >retainCount (From: Markus Hitter <email@hidden>) |