@property(readwrite,nonatomic,assign,getter = isCancelled)BOOL取消 - xcode6导致编译错误

liv*_*v a 8 sdk xcode ios

我一直在使用AFNetworking处理xco​​de 5.0.2,一切都运行得很好.当我升级到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
Run Code Online (Sandbox Code Playgroud)

和错误: Use of undeclared identifier '_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];
}
Run Code Online (Sandbox Code Playgroud)

我在SO上找到了这个答案,并下载了xcode 5.1.1复制了库,就像建议将基本sdk设置为7.1并且错误仍然存​​在

有什么建议?

Ace*_*cey 4

NSOperation更改了它的几个属性的读取访问器名称,cancel -> isCancelled 和 finish -> isFinished (我认为)。以前它们是方法,但现在它们是属性。

AFNetworking需要更新到具有固定合成的版本。AFURLConnectionOperation.m 文件现在具有以下内容来修复此问题。

@synthesize cancelled = _cancelled;
Run Code Online (Sandbox Code Playgroud)