Re: Should the analyzer catch retained objects returned from createXXX methods?
Re: Should the analyzer catch retained objects returned from createXXX methods?
- Subject: Re: Should the analyzer catch retained objects returned from createXXX methods?
- From: Ken Thomases <email@hidden>
- Date: Wed, 17 Aug 2011 16:22:36 -0500
On Aug 17, 2011, at 4:06 PM, Rick Mann wrote:
> I have a method named createFoo, from which I return an object with a retain count of 1. The Xc4 static analyzer is complaining about a potential leak, but I thought it would notice the "create" in the name...
"Create" in a name is a Core Foundation convention, not a Cocoa convention. This is specifically called out in the Memory Management Programming Guide <http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html>:
> Important: There are similar memory management rules for Core Foundation objects (see Memory Management Programming Guide for Core Foundation). The naming conventions for Cocoa and Core Foundation, however, are different. In particular, Core Foundation’s “create rule in Memory Management Programming Guide for Core Foundation” does not apply to methods that return Objective-C objects. For example, in the following code fragment, you are _not_ responsible for relinquishing ownership of myInstance:
>
> MyClass *myInstance = [MyClass createInstance];
Regards,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden