将“__unsafe_unretained id *”转换为“const void **”

Max*_*Max 2 objective-c ios automatic-ref-counting

我正在尝试[NSMutableDictionary dictionaryWithObjects:frames forKeys:items]使用 CFDictionary 来实现,这样我就可以控制键和值回调。这就是我所拥有的:

__unsafe_unretained id keys[itemCount];
[items getObjects:keys range:NSMakeRange(0, itemCount)];
__unsafe_unretained id values[itemCount];
[frames getObjects:values range:NSMakeRange(0, itemCount)];
CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)values, itemCount, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
Run Code Online (Sandbox Code Playgroud)

这给出了以下错误:Cast of an indirect pointer to an Objective-C pointer to 'const void **' is disallowed with ARC

我尝试了各种桥接排列,但我似乎无法毫无抱怨地编译它。

非常感谢任何帮助!

rob*_*off 5

我也找不到相应的语法。(编辑:贾斯汀的答案有语法。)试试这个:

void *keys[itemCount];
[items getObjects:(__unsafe_unretained id *)(void *)keys range:NSMakeRange(0, itemCount)];
Run Code Online (Sandbox Code Playgroud)

那么当你调用时就不需要演员表了CFDictionaryCreate