Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled - xcode6 cause compiler error

Tags:

xcode

ios

sdk

I've been working on xcode 5.0.2 with AFNetworking, everything worked perfectly. when I upgraded to xcode 6 GM I got the warnining: Auto property synthesis will not synthesize property 'cancelled' because it is 'readwrite' but it will be synthesized 'readonly' via another property on this line:

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

and error: 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];
}

I found this answer on SO and downloaded xcode 5.1.1 copied the library like suggested set the base sdk to 7.1 and the error remains

any suggestions?

like image 485
liv a Avatar asked Sep 15 '14 03:09

liv a


1 Answers

NSOperation changed the read accessor names for a couple of its properties, cancelled -> isCancelled and finished -> isFinished (I think). Before they were methods, but now they are properties.

AFNetworking needs to be updated to a version that has the fixed synthesizing. The AFURLConnectionOperation.m file now has the following to fix this issue.

@synthesize cancelled = _cancelled;
like image 187
Acey Avatar answered Oct 26 '22 11:10

Acey