参见英文答案 >
Swift 3.0 unresolved identifier for DispatchQueue2个
我试图在主线程上异步拍摄/录制视频.但是,当我调用dispatch.main.async时,我总是收到错误:
我试图在主线程上异步拍摄/录制视频.但是,当我调用dispatch.main.async时,我总是收到错误:
use of unresolved identifier DispatchQueue
从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: nil) } }) } } }) } } else { self.cameraEngine.stopRecordingVideo() } }