• 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: j o a r <email@hidden>
  • Date: Fri, 26 Sep 2003 10:31:29 +0200

The answer IS in the docs:

<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ Concepts/ObjectOwnership.html>

"A body of code should never be concerned with releasing something it did not create. Therefore, Cocoa sets this policy: If you directly create an object (using alloc, allocWithZone:, or new) or copy an object (using copy, copyWithZone:, mutableCopy, or mutableCopyWithZone:), you are responsible for releasing it. If you did not directly create or copy the object, you do not own it and should not release it."

Did you call alloc, new or copy to get the object? No you did not, and so should not release it. It's dead simple!

j o a r

On 2003-09-26, at 10.10, Jirome Foucher wrote:

I didn't find the answer in the doc nor in the books I have, so here it is :

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 ?
_______________________________________________
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:
    • Re: stringByAppendingBlahBlah woes
      • From: Jérome Foucher <email@hidden>
References: 
 >stringByAppendingBlahBlah woes (From: Jérome Foucher <email@hidden>)

  • Prev by Date: Re: Is Cocoa+Java considered relevant to the list?
  • Next by Date: Re: stringByAppendingBlahBlah woes
  • Previous by thread: stringByAppendingBlahBlah woes
  • Next by thread: Re: stringByAppendingBlahBlah woes
  • Index(es):
    • Date
    • Thread