Cocoa methods that return CF objects

André Pang ozone at algorithm.com.au
Wed Jul 2 22:03:25 PDT 2008


Hi, two questions:

1. What's the generally accepted memory management convention for  
Cocoa methods that return Core Foundation objects?  I presumed that it  
would have been "the caller is responsible for sending CFRelease() to  
the returned object", but then I saw that some methods, e.g. - 
[NSBitmapImageRep CGImage], return autoreleased CF objects.  That  
leads me to the second question...

2. Is it _always_ fine to send -autorelease to Core Foundation  
objects?  Writing  [(id)coreFoundationObject autorelease] to avoid  
compiler warnings feels kinda weird, though admittedly the new-skool  
[NSMakeCollectable(coreFoundationObject) autorelease] looks a little  
better...

Thanks,
Andre.


-- 
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>





More information about the MacOSX-dev mailing list