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

我一直在使用AFNetworking处理xco​​de 5.0.2,一切都很完美.
当我升级xcode 6 GM时,我得到了警告:自动属性合成不会合成属性’已取消’,因为它是’readwrite’但它将通过此​​行上的另一个属性合成’readonly’:
@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];
}

我在SO上发现this answer并下载xcode 5.1.1复制了库,就像建议将基本sdk设置为7.1并且错误仍然存​​在

有什么建议?

解决方法

NSOperation更改了其几个属性的读取访问者名称,取消了 – > isCancelled and finished – > isFinished(我想).在他们成为方法之前,但现在他们是属性.

AFNetworking需要更新为具有固定合成的版本. AFURLConnectionoperation.m文件现在具有以下解决此问题的方法.

@synthesize cancelled = _cancelled;

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...