尝试使用 dispatch_async 我需要一个可抛出的调用,但是 Swift 的新错误处理和方法调用让我感到困惑,如果有人能告诉我如何正确地做到这一点,或者指出我正确的方向,我将不胜感激。
代码:
func focusAndExposeAtPoint(point: CGPoint) {
dispatch_async(sessionQueue) {
var device: AVCaptureDevice = self.videoDeviceInput.device
do {
try device.lockForConfiguration()
if device.focusPointOfInterestSupported && device.isFocusModeSupported(AVCaptureFocusMode.AutoFocus) {
device.focusPointOfInterest = point
device.focusMode = AVCaptureFocusMode.AutoFocus
}
if device.exposurePointOfInterestSupported && device.isExposureModeSupported(AVCaptureExposureMode.AutoExpose) {
device.exposurePointOfInterest = point
device.exposureMode = AVCaptureExposureMode.AutoExpose
}
device.unlockForConfiguration()
} catch let error as NSError {
print(error)
}
}
}
警告:
: 从 '() throws -> _' 类型的抛出函数到非抛出函数类型 '@convention(block) () -> Void' 的无效转换