Cocoa methods that return CF objects
Christiaan Hofman
cmhofman at gmail.com
Mon Jul 7 03:11:30 PDT 2008
On 5 Jul 2008, at 6:03 PM, Uli Kusterer wrote:
> On 05.07.2008, at 16:19, Jim Correia wrote:
>> On Jul 5, 2008, at 5:37 AM, Uli Kusterer wrote:
>>
>>> At least I think so. I remember painstakingly swizzling so I can
>>> log retain/release calls, only to find that CFRetain() on a
>>> CFArrayRef didn't trigger my override, and I think the above was
>>> the reason I determined back then.
>>
>> In its current implementation, CFRetain will send -retain to the
>> object if the argument is an obj-c object, otherwise do the CF
>> retain count dance.
>
>
> OK, I stand corrected, that matches with observed behaviour. Trouble
> is just, I really wanted to override retain/release, breakpoints
> weren't really enough... and I wasn't able to find a way to tell
> CFRetain/CFRelease to call me when they do their work. Tried lots of
> things, custom allocators etc., but there seems to be some
> information missing in the retain callbacks and similar.
>
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
I don't think there is a way to do this. When a method is overridden
without calling super, you can make any override or swizzle any method
you want in the root class, but it makes no difference. The only thing
you could do is plug into the basic method dispatch mechanism. There
was a thread on this not so long ago. However this probably may also
be ignored for toll-free bridged objects. Also note that in many cases
where you would expect CFRetain to be called, in fact it's not used,
rather the underlying memory management functions are used directly
(e.g. in standard kCFType... CF collection callbacks, as I just
discovered, as well as CFMakeCollectable()).
Christiaan
More information about the MacOSX-dev
mailing list