xCode 6如何修复“未声明的标识符的使用”用于自动属性合成? [英] xCode 6 how to fix "Use of undeclared identifier" for automatic property synthesis?
问题描述
我使用xCode6 Beta 3,并且遇到一个问题,其中以前编译好的代码(xCode 5.1.1或xCode6 beta 2)突然开始给我使用未声明的标识符错误:
I'm using xCode6 Beta 3, and am running into an issue where a code which previously compiled fine (xCode 5.1.1 or xCode6 beta 2) suddenly started to give me "Use of undeclared identifier" errors when accessing an automatically synthesized instance variable:
- (void)setFinished:(BOOL)finished {
[self willChangeValueForKey:@"isFinished"];
_finished = finished;
[self didChangeValueForKey:@"isFinished"];
}
//ERROR:
Use of undeclared identifier '_finished'; did you mean 'finished'?
添加 @synthesize finished = _finished;
错误消失了,但是否有办法强制xCode6 Beta 3使用自动属性合成使用下划线符号?
推荐答案
起初我以为这是一个测试版本的错误,但今天我看到这种类型的错误发生在XCode 6转基因种子也,虽然我还没有发现在哪些特定的情况下。
At first I thought it was a beta version bug, but today I saw that this type of errors occur on the XCode 6 GM Seed also, though I'm yet to discover in which particular cases.
无论如何,修复是在@implementation块中添加一个synthesize语句,显式声明ivar的名称以及属性:
Anyway, the fix is to add a synthesize statement in the @implementation block, explicitly declaring the name of the ivar as well as the property:
@synthesize property = _property
这篇关于xCode 6如何修复“未声明的标识符的使用”用于自动属性合成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!