@property (readwrite, nonatomic, assign, getter=isCancelled) BOOL cancelled - Xcode6导致编译器错误。

8

我一直在使用xcode 5.0.2和AFNetworking进行工作,一切都运行得非常完美。但当我升级到xcode 6 GM版本时,我收到了警告:Auto property synthesis will not synthesize property 'cancelled' because it is 'readwrite' but it will be synthesized 'readonly' via another property该警告出现在以下代码行:

@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled

并出现错误: 使用未声明的标识符'_cancelled'

- (void)cancel {
    [self.lock lock];
    if (![self isFinished] && ![self isCancelled]) {
        [self willChangeValueForKey:@"isCancelled"];
        _cancelled = YES; <-- THIS LINE CAUSES THE ERROR
        [super cancel];
        [self didChangeValueForKey:@"isCancelled"];

        // Cancel the connection on the thread it runs on to prevent race conditions
        [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
    }
    [self.lock unlock];
}

我在stackoverflow上找到了这个答案,下载了Xcode 5.1.1并像建议的那样复制库,将基本SDK设置为7.1,但错误仍然存在。有什么建议吗?

为什么要费这个劲呢?如果你真的想继续使用Xcode 5,那就用Xcode 5.1 - 它支持iOS 7.1。但是现在你真的应该开始使用Xcode 6并为iOS 8开发。 - rmaddy
@nyekimov 如果你仔细阅读我的问题,你会发现我正在使用的是xcode 5.0.2,因此我没有xcode 5.1可以从sdk中复制-->这就是为什么我在问这个问题。 - liv a
@rmaddy,我已经下载了XCode 6开始使用它,但是出现了需要修复的编译器错误! - liv a
所以修复代码。没有必要在Xcode 6中安装不同的SDK。 - rmaddy
@liva 只需将 ivar 添加到类中即可。 - rmaddy
显示剩余4条评论
1个回答

4

NSOperation 更改了一些属性的读取器名称,cancelled -> isCancelled 和 finished -> isFinished(我认为)。之前它们是方法,但现在它们是属性。

AFNetworking 需要更新到具有修复综合的版本。现在,AFURLConnectionOperation.m文件具有以下内容以解决此问题。

@synthesize cancelled = _cancelled;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接