本文介绍了迅速3中的dispatchqueue显示为未解析的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在主线程上异步拍摄/录制视频.但是,当我呼叫dispatch.main.async
时,总是收到错误消息:
I am trying to take/record video asynchronously on the main thread. However, when I call dispatch.main.async
, I always get the error:
use of unresolved identifier DispatchQueue
从WWDC到Apple的文档,我到处都看过,但是我看不到任何类型的证据.
I've looked everywhere from WWDC to Apple's Documentation, but I see no evidence of the type being deprecated.
这是代码:
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()
}
}
推荐答案
您可以放
import Foundation
或
import Dispatch
在代码的开头即可开始使用 DispatchQueue类,没有任何问题.
at the beginning of your code to start using DispatchQueue class without any issue.
这篇关于迅速3中的dispatchqueue显示为未解析的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!