NSOperationQueue - dependency not respected

I am using an NSOperationQueue for an upload task.

Code Block
self.operationQueue = [[NSOperationQueue alloc] init];
self.operationQueue.maxConcurrentOperationCount = 5;


There are two types of tasks - UploadChunkTask and FinalTask (NSOperation subclasses). I'd like the FinalTask to start after all the UploadChunkTasks are finished. So I add the tasks for chunk uploads as dependencies to the final task:

Code Block
FinalTask *finalOperation = [[FinalTask alloc] init];
for (int i = 0; i < self.file.numberOfChunks; i++) {
UploadChunkTask *uploadOperation = [[UploadChunkTask alloc] initWithFile:self.file andChunkNumber:i+1];
[uploadOperations addObject:uploadOperation];
[finalOperation addDependency:uploadOperation];
}
[uploadOperations addObject:finalOperation];

And finally I add the tasks to an NSOperationQueue:

Code Block
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.operationQueue addOperations:uploadOperations waitUntilFinished:YES];
dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
});


The problem is that the final task does not respect the dependency and gets executed with the other tasks (instead of waiting for them to finish first). This happens even if there is just one upload task. The final task is sometimes executed before the upload task. I noticed this issue disappears if maxConcurrentOperationCount is set to 1, but I need it to be set to 5. Thank you in advance.