开发者

CFDictionaryValueCallBacks retain/release?

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, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜