• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: retainCount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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>)

  • Prev by Date: retainCount
  • Next by Date: Re: interthread communication
  • Previous by thread: retainCount
  • Next by thread: Re: retainCount
  • Index(es):
    • Date
    • Thread