• 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
Will this cause a leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Will this cause a leak?


  • Subject: Will this cause a leak?
  • From: "Zameer Andani" <email@hidden>
  • Date: Wed, 27 Jul 2005 11:06:07 -0700
  • Thread-topic: Composite values using Core Data and Cocoa Bindings

I'm a little confused with the concept of autorelease, I've read all the documentation about the topic that has been posted thus far in the forum and I find myself still confused.  Can someone perhaps still clarify.

For example if I had the following:

-(NSString*) Foo
{
	NSString *myString  = [[NSString alloc] initWithString:@"This is a test"];  //at this point retainCount = 1
	return [myString autorelease]; //Have I leaked?
}

>From experimentation, I have found that autorelease does not decrement the retain count, if anything it will increment the retain count.
So do I need to explicitly call [release] on the object before returning out of the method?  Should my code be changed to look like:

[myString autorelease];
[myString release];
return myString

thanks for the help...
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Will this cause a leak?
      • From: Pontus Ilbring <email@hidden>
  • Prev by Date: Re: Composite values using Core Data and Cocoa Bindings
  • Next by Date: Re: Setting vertical alignment for a NSTextFieldCell ?
  • Previous by thread: Re: Disposing of a Nib file
  • Next by thread: Re: Will this cause a leak?
  • Index(es):
    • Date
    • Thread