So I'm a bit confused about how my NSOperation subclass should implement the cancel method. The documentation says that "isCancelled" is a KVO-compliant property. So I figured that calling [super cancel] ought to take care of that. But it doesn't. Doesn't appear to do anything, actually, whether I call it or not [self isCancelled] still returns the expected value in my -start method, but no apparent isCancelled KVO notification is generated. So I decided to implement my cancel method as

- (void)cancel
{
   // if we have started the operation, cancel it
   if (self.downloadConnection)
      [self.downloadConnection cancel];

   // this generates isExecuting and isFinished notifications as needed
   [self sendKVONotifications:nil];

   // ok ... what should we do about the isCancelled property?
   [self willChangeValueForKey:@"isCancelled"];
   [super cancel];
   [self didChangeValueForKey:@"isCancelled"];
}

... which just doesn't seem quite right. What's the correct thing to do?

--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

"I just can't accept that 24 reserves, 3 hospitalizations and
 one fatality are in any way acceptable for what should be the
 premier event on the paragliding calendar." -- Mark Hayman



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to