ARC不允许将非Objective-C指针类型'void *'隐式转换为'__unsafe_unretained id *'

时间:2012-01-12 10:57:16

标签: objective-c xcode4.2 automatic-ref-counting

我正在尝试迁移到ARC但我收到此错误,我真的不知道如何解决这个问题:

    NSArray *itemsArray = nil;

    __unsafe_unretained id *objArray = calloc (itemRange.length, sizeof (id)); //got the error here
    [fdEntries getObjects:objArray range:itemRange]; //fdEntries is an NSMutableArray
    itemsArray = [NSArray arrayWithObjects:objArray count:itemRange.length];
    free(objArray);

以下是错误:自动引用计数问题:ARC不允许将非Objective-C指针类型'void *'隐式转换为'__unsafe_unretained id *'。

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

您的代码可以由没有手动内存管理的解决方案替换:

 NSArray *itemsArray = [fdEntries subarrayWithRange:itemRange];