I need to run several functions and the order in which the functions are executed is very important. I have two non-async functions that need to be run and then two async functions that need to be executed after that. All of the functions must be executed upon the completion of the previous function.
So far I have the following. However, the async functions do not seem to follow the dependencies that I have laid out. Both async functions are executed as soon as the queue begins.
Is there something I am missing? Any help is appreciated! :)
let queue = OperationQueue()
let operation1 = BlockOperation {
nonAsyncFunc1()
}
let operation2 = BlockOperation {
nonAsyncFunc2()
}
let operation3 = BlockOperation {
asyncFunc1()
}
let operation4 = BlockOperation {
asyncFunc2()
}
operation2.addDependency(operation1)
operation3.addDependency(operation2)
operation4.addDependency(operation3)
self.queue.addOperation(operation1)
self.queue.addOperation(operation2)
self.queue.addOperation(operation3)
self.queue.addOperation(operation4)