Add an observer to your class that listens for changes to the isFinished value of the NSOperation subclass
[operation addObserver:self forKeyPath:@"isFinished" options:NSKeyValueObservingOptionNew context:SOME_CONTEXT];
Then implement the following method, looking for the context registered as a listener. You can make the data that you want to retrieve from a subclass of NSOperation accessible through the method / property of the access method.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
Check out KVO Programming and Parallel Programming.
Also note that the observer will be received in the same thread as the operation, so you may need to run the code in the main thread if you want to work with the user interface.
Jablair
source share