I tried something like
_queue = [[NSOperationQueue alloc] init];
[_queue addObserver:self forKeyPath:@"operations" options:NSKeyValueObservingOptionNew context:NULL];
for(NSString *url in [_filesToDownload allKeys]) {
UrlDownloaderOperation * operation = [UrlDownloaderOperation urlDownloaderWithUrlString:url folderName:folder fileName: [_filesToDownload objectForKey:url]];
[_queue addOperation:operation];
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
}
But, it crashes with below error message
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(
Date,
"Cache-Control",
Expires,
"Last-Modified",
"Accept-Ranges",
"Content-Length",
"Content-Type",
Age,
Connection,
Server
): An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: operations
Observed object: <NSOperationQueue: 0x1d2f80>
Change: {
indexes = <NSMutableIndexSet: 0x73314f0>[number of indexes: 1 (in 1 ranges), indexes: (0)];
kind = 3;
}
Context: 0x0'