On Oct 20, 2011, at 4:43 PM, Matt Neuburg wrote: > Sure, but still, he's returning a retained CGColorRef. And CGColor > participates in this convention (CGColorRelease, CGColorRetain, CGColorCreate > etc.). I'm not saying he has to do it; I'm merely suggesting that the magic > word "Create" will help him remember what he's trying to remember, namely > that he's returning a retained CGColorRef and the caller will need to call > CGColorRelease on it later.
You're absolutely right, Matt. But it's actually more fundamental than that, now that Xcode 4 has the Analyze command. I don't believe this is documented, but I found out by trial and error that the Core Foundation "create rule" should be followed in Cocoa methods that return Core Foundation CFTypeRef objects, if you want to get optimum results from Analyze. Specifically, if your Cocoa method returns a CFTypeRef object retained, and you don't put "Copy" or "Create" in the method name, Analyze reports a "potential" memory leak. Go back and insert "Copy" or "Create" into the method name, and Analyze no longer reports a potential memory leak. To me, it makes all the sense in the world to apply the "create rule" to Cocoa methods that return Core Foundation CFTypeRef objects. I found this discovery extraordinarily helpful in using Analyze to kill memory issues in a couple of frameworks I distribute. The frameworks make heavy use of CFTypeRef objects. I would love to hear from anybody at Apple who can confirm that this is the way Analyze is meant to work. -- Bill Cheeseman - b...@cheeseman.name _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com