Cocoa methods that return CF objects

Jim Correia jim.correia at pobox.com
Thu Jul 3 06:30:48 PDT 2008


On Jul 3, 2008, at 5:11 AM, Christiaan Hofman wrote:

> AFAIK, CFType (= CoreFoundation "root class") is toll free bridged  
> to NSObject. This means that you can send any valid NSObject method  
> to a CoreFoundation object, and v.v. pass any Cocoa object to a  
> CoreFoundation function that accepts a CFType (s.a. CFRetain(),  
> CFRelease()).
>
> However I am not 100%, and I've never been able to find this in the  
> docs. I believe this is an omission in the docs. E.g. I am 100% sure  
> that I can use generic CFType methods s.a. CFRetain/CFRelease with a  
> Cocoa object (and that's used a lot in Cocoa+Carbon code, including  
> lots of sample code), while I've never seen an explicit reference in  
> the docs to this fact. I think I will file a documentation bug. And  
> I would appreciate if someone who does know could pass a reference  
> to relevant documentation, or confirm my statement.

When building an Obj-C application with classic memory management, - 
retain/CFRetain are equivalent, as are -release/-autorelease/CFRelease.

In a GC application, they are not equivalent. (In fact, -release/- 
autorelease are no-ops, while CFRelease is not.)

<http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html 
 >

Jim


More information about the MacOSX-dev mailing list