Re: Releasing NSSearchPathForDirectoriesInDomain causes crash
Re: Releasing NSSearchPathForDirectoriesInDomain causes crash
- Subject: Re: Releasing NSSearchPathForDirectoriesInDomain causes crash
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 01 Oct 2009 19:28:07 -0700
On Oct 1, 2009, at 8:42 AM, Jens Alfke wrote:
On Sep 30, 2009, at 7:37 PM, Adam R. Maxwell wrote:
Does the Cocoa memory management documentation cover functions? It
specifically refers to "...a method whose name begins with...". I
wonder if something like the CF "Create" rule applies to Foundation?
No — Foundation functions almost never return references that you
need to release. The only exceptions I can think of are a few low-
level functions intended to be used for custom object allocation/
copying, like NSAllocateObject and NSCopyObject.
As I pointed out last night, NSCreateMapTable/NSCreateHashTable return
references that you need to free, as well (as does NSCreateZone). The
NSCreateFile... functions evidently follow a "get" rule, as does
NSSearchPathForDirectoriesInDomain.
The reason for CF's "Create" and "Copy" naming rule is that CF
doesn't have autorelease, so functions that might return newly-
created objects have no choice but to hand the responsibility to the
caller.
Right, I understand that. It just seems to me that there's no
meaningful naming convention for Foundation functions with respect to
memory management.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden