Is there a constant retain callback I can use for generic id
/ NSObject
s ? There is kCFTypeDictionaryValueCallBacks
but they're only for "CFType-derived objects." I don't believe NSObjects are CFTypes, so I wrote these:
const void *valueRetainCallBack(CFAllocat开发者_JAVA技巧orRef allocator, const void *ptr)
{
id o = (id)ptr;
[o retain];
return o;
}
void valueReleaseCallBack(CFAllocatorRef allocator, const void *ptr)
{
id o = (id)ptr;
[o release];
}
But perhaps there is a simpler way?
Is there a constant retain callback I can use for generic id / NSObjects ? There is
kCFTypeDictionaryValueCallBacks
but they're only for "CFType-derived objects." I don't believe NSObjects are CFTypes…
They're not documented as fully bridged, but for memory management (retain and release), that's documented to work. In practice, all the functions common to CFType and NSObject, including description
/CFCopyDescription
, work as well.
精彩评论