我试图在主线程上异步拍摄/录制视频.但是,当我打电话时dispatch.main.async,我总是得到错误:
use of unresolved identifier DispatchQueue
Run Code Online (Sandbox Code Playgroud)
从WWDC到Apple的文档我到处都是,但我看不到这种类型被弃用的证据.
这是代码:
if !self.cameraEngine.isRecording {
if let url = CameraEngineFileManager.temporaryPath("video.mp4") {
self.cameraButton.setTitle("stop recording", forState: [])
self.cameraEngine.startRecordingVideo(url, blockCompletion: { (url: NSURL?, error: NSError?) -> (Void) in
if let url = url {
DispatchQueue.main.async {
self.cameraButton.setTitle("start recording", for: .normal)
CameraEngineFileManager.saveVideo(url, blockCompletion: { (success: Bool, error: Error?) -> (Void) in
if success {
let alertController = UIAlertController(title: "Success, video saved !", message: nil, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alertController, animated: true, completion: …Run Code Online (Sandbox Code Playgroud)