【问题标题】:Implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARCARC 不允许将非 Objective-C 指针类型“void *”隐式转换为“__unsafe_unretained id *”
【发布时间】:2012-02-08 16:08:54
【问题描述】:

我正在尝试迁移到 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 *”。

感谢您的帮助!

【问题讨论】:

  • 你想做什么 - 你是不是想不使用 alloc 对象数组?

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


【解决方案1】:

您的代码可以替换为无需手动内存管理的解决方案:

 NSArray *itemsArray = [fdEntries subarrayWithRange:itemRange];

【讨论】:

  • 好的,我会尝试解决方案,我会尽快通知您...谢谢
猜你喜欢
  • 1970-01-01
  • 2011-10-15
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多