Cocoa methods that return CF objects
Christiaan Hofman
cmhofman at gmail.com
Sat Jul 5 02:44:23 PDT 2008
On 5 Jul 2008, at 4:15 AM, Jim Correia wrote:
> On Jul 4, 2008, at 8:26 PM, Gary L. Wade wrote:
>
>> Without confirmation from Apple, you're pretty much stuck with
>> empirical testing whether you believe you should or should not have
>> to do it. What value is returned when you call CFGetTypeID for an
>> object subclassed from NSObject or even an object of type NSObject?
>
> Well, there are actually 2 questions to ask/answer here.
>
> What is the documented behavior/contract? (This we can rely upon
> from release to release of the OS/frameworks.)
>
Well, I think that's clear: according to the documentation, you can
only use toll-free bridging for explicitly toll-free bridged
subclasses, not for generic CFTypes/NSObjects. The only exception I
know is CFRetain and CFRelease, which are (now) mentioned as being
safe for any Cocoa object. However this is (explicitly) mentioned in
the wrong place and in the wrong context (the GC docs rather the Cocoa
+Carbon docs, and in an example). Moreover, I believe this is only
included in the Leopard docs, I had never seen it mentioned in the
earlier docs. So can we rely on it on Tiger? I have seen several
mailing list messages from Apple engineers to certify that they were
safe way back. Moreover, as I said, the fact that they are is pretty
essential for Cocoa+Carbon.
> What does CF do?
>
> When the documentation is lacking (is it, in this case?),
For sure. It certainly is not there in the place where it should be. I
asked if it was somewhere else, and until now nobody has provided a
link that affirms the minimum of what I'm pretty sure is supported
(based on mailing lists). Also, it's an important fact that should be
mentioned *explicitly* in the Carbon-Cocoa guide, not mentioned in
passing in an example (and more fully). So, yes, the documentation is
lacking.
> the answer can be found by reading the CF Lite source code.
> CFGetTypeID will return whatever is returned by -_cfTypeID when the
> input is an Obj-C object.
>
> Jim
In fact it returns 1 for me for any Cocoa object that's not explicitly
toll-free bridged.
Christiaan
More information about the MacOSX-dev
mailing list