How can i set the priority in NSOperationQueue to not execute the next operation until the previous operation is finished?
NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
[operationQueue setMaxConcurrentOperationCount:1];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(addPhotoWithButton:) object:button];
[operationQueue addOperation:operation];
[operation release];
Assuming that you mean that you want to execute the operations serially or one at a time then I think your problem is that you are calling setMaxConcurrentOperationCount: with 1 and then losing the reference to that operation queue by overwriting it with another operation queue. So what you are doing is correct, you just need to add the operation to the queue with the desired operation count. You probably did not mean to do this, in fact, I would think you would be seeing a compiler warning. Try this code: