The easiest approach is simply to have your NSOperation's main
post an NSNotification at the end of itself. Thus, anyone else can register for that notification and learn that the operation is over (and can come back to the NSOperation to pick up any data stored in properties that may be needed).
Here's a typical structure:
- (void) main {
if ([self isCancelled])
return;
// ... all the action goes here ...
if (![self isCancelled])
[[NSNotificationCenter defaultCenter]
postNotificationName:@"OperationFinished" object:self];
}
Note that you should make no assumptions about what thread the NSNotification arrives on.
The alternative is to use KVO on the NSOperation's isFinished
, but this can get hairy and I'm not sure I would advise it.