【问题标题】:@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled - xcode6 cause compiler error@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL 取消 - xcode6 导致编译器错误
【发布时间】:2014-09-15 03:04:35
【问题描述】:

我一直在使用 AFNetworking 开发 xcode 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

和错误: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];
}

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

有什么建议吗?

【问题讨论】:

  • stackoverflow.com/questions/24083358/… 已经有了答案,说明如何从 xcode 5.1 手动复制 sdk。
  • 为什么要打扰这个?如果您真的想继续使用 Xcode 5,请使用 Xcode 5.1 - 它有 iOS 7.1。但是你现在真的应该开始使用 Xcode 6 并为 iOS 8 开发。
  • @nyekimov 如果您仔细阅读我的问题,您会发现我使用的是 xcode 5.0.2,因此我没有从 sdk 复制的 xcode 5.1 -->这就是我问的原因问题
  • @rmaddy 我已经下载了 XCode 6 以开始使用它,但是有一个编译器错误需要修复!
  • 所以修复代码。无需在 Xcode 6 中安装不同的 SDK。

标签: ios xcode sdk


【解决方案1】:

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

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

@synthesize cancelled = _cancelled;

【讨论】:

    猜你喜欢
    • 2011-07-18
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多