• 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: stringByAppendingBlahBlah woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringByAppendingBlahBlah woes


  • Subject: Re: stringByAppendingBlahBlah woes
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Fri, 26 Sep 2003 16:20:26 +0200

At 10:10 Uhr +0200 26.09.2003, Jirome Foucher wrote:
if I call :
NSString* path;
path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
exists = [[NSFileManager defaultManager] fileExistsAtPath:path];

do I have to release path ? or will it be autoreleased ? or do I have to bracket the call by an NSAutoReleasePool ?

It will be autoreleased. That means there at least needs to be an NSAutoreleasePool somewhere. If you're in your app's main thread, you get an autorelease pool for free in the event loop. If you are using this in a tight loop, it may be a good idea to put an autorelease pool inside your loop.

As always, if there is "load", "new", "alloc" or "copy" in the method name, you're responsible for releasing it. Otherwise, it is autoreleased or it is owned by the object on which you called the method, which means they'll take care of disposing of it.

This is also mentioned in this list's inofficial FAQ at:

http://www.alastairs-place.net/blog/blog/CocoaDev-faq.txt
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.

  • Follow-Ups:
    • FAQ
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >stringByAppendingBlahBlah woes (From: Jérome Foucher <email@hidden>)

  • Prev by Date: Re: Cocoa FAQ Baby Steps - (was Re: Strange warnings)
  • Next by Date: unsubsribe
  • Previous by thread: Re: stringByAppendingBlahBlah woes
  • Next by thread: FAQ
  • Index(es):
    • Date
    • Thread