I use "capturePhotoWithSettings:delegate:" to capture still image. how to make sure the callback invokes in a common queue, not in main queue?
How to make AVCapturePhotoOutput invokes the AVCapturePhotoCaptureDelegate callbacks on a common dispatch queue, not in the main queue
If you are running other methods in captureOutput callback that also needs to be run on main queue (e.g. UI updates) and is causing a deadlock in captureOutput, solution is to run your methods in an asynchronous dispatch call to the global queue. Example below:
__weak __typeof(self) weakSelf = self; // Prevents retain cycles
// Dispatch async call from AVCapturePhotoOutput's captureOutput method call
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ (){
__typeof(self) strongSelf = weakSelf; // Ensures weak self is not released
if (strongSelf) {
// Insert method(s) to run on common queue here
}
});