I had the same problem when creating against iOS 5. I ended up creating a flag named operationStarted , which was NO by default, and I switched to YES when the start method was called. Then, in my finish method (where I generate KVO notifications), I checked the flag value before starting the notifications.
The flag definition looks like this:
@property (nonatomic, assign, getter=isOperationStarted) BOOL operationStarted;
start method:
- (void)start { [self setOperationStarted:YES]; ... }
My finish method, which is called when the operation is completed or canceled:
- (void)finish { if (![self isOperationStarted]) return; [self willChangeValueForKey:@"isExecuting"]; executing = NO; [self didChangeValueForKey:@"isExecuting"]; [self willChangeValueForKey:@"isFinished"]; finished = YES; [self didChangeValueForKey:@"isFinished"]; }
It ended up resolving the issue for me. Hope this helps someone else.
RJ Regenold
source share