转换为自动引用计数(ARC):“使用未声明的标识符”错误

时间:2013-09-13 07:10:12

标签: xcode compiler-construction properties compilation automatic-ref-counting

在一个非常大的项目中我到处都使用了自动合成的属性:

//MyClass.h file:
@interface MyClass : NSObject

@property (nonatomic, retain) NSString *deviceName;
@property (nonatomic, retain) NSString *deviceID;

@end

//MyClass.m file:
#import "MyClass.h"

@implementation ApplicationStatus
// no @synthesize used at all.

-(void)dealloc{

    [_deviceName release]; // gives errors only while converting to ARC with LLVM 5.0
    [_deviceID release];

    [super dealloc];
}

@end

上面的代码在非ARC模式下以及在ARC转换过程中的旧Xcode版本中编译得很好。 当尝试使用最新的LLVM 5.0编译器(最新的Xcode)进行转换时,它给了我数以百万计的错误: enter image description here

这是什么原因?我是否必须手动创建数百个实例变量并现在手动@synthesize它们?这不是苹果公司在所有WWDC上宣传的“少写代码”理念的退步吗?

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。

在Apple的指导下,我虔诚地使用self.之外的init_ init。 当您在Xcode 5中迁移到ARC时,这会中断。

我发现最简单的方法是:

@synthesise deviceName = _deviceName;

更改所有引用只是愚蠢,痛苦和错误,对于只读变量,甚至不是一个选项。

自动完成功能在设置综合语句时非常聪明,您只需要将它们用于init中要访问的内容。

相关问题