I am adding operations to the queue using something like this
NSInvocationOperation *operation0 = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@s
Without extra code, you can't really guarantee that your NSOperations will run in serial - if Apple release a multiprocessor iOS device, it will run multiple operations in parallel. So firstly, you should set up the dependency chain between your operations. I would suggest that you achieve this using NSOperation's - (void)addDependency:(NSOperation *)operation
. You could also roll your own fancy locking code...
You can then add a sleep(5) to the end of each of your doStuff methods. If you need the sleep outside the doStuff methods, create a sleep NSOperation:
- (void)sleepOperationBody; {
sleep(0.5f);
}
NSInvocationOperation *operation1 = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(sleepOperationBody)
object:nil];
That said, without knowing in more detail what you need to happen, I think you perhaps just need one NSOperation that combines all three tasks and puts a sleep between them. That would certainly be simpler code.