• 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: where does one do the autorelease?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where does one do the autorelease?


  • Subject: Re: where does one do the autorelease?
  • From: James DiPalma <email@hidden>
  • Date: Thu, 22 Jul 2004 12:10:07 -0700

COMMENT = [[NSString alloc] initWithString:@""];
[COMMENT autorelease];

Before, this code would end up leaking your old value and then releasing your new COMMENT value.

You got it right once (autorelease your old value, retain your new value):

[COMMENT autorelease];
COMMENT = [str copy];

But it seems by accident:

Where does one put the autorelease in the else clause, before or after
the init? I think after but before I change lots of code I'd like to be
right ;)

Please try and understand what your code is doing and why. Read some documentation on object ownership rules.


-jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >where does one do the autorelease? (From: John Spicer <email@hidden>)

  • Prev by Date: Re: Redirecting screencapture output
  • Next by Date: Re: Tiger for ASD?
  • Previous by thread: Re: where does one do the autorelease?
  • Next by thread: ZeroLink Errors
  • Index(es):
    • Date
    • Thread