【发布时间】:2015-07-28 01:43:31
【问题描述】:
尝试使用 dispatch_async 我需要一个 throwable 调用,但是 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' 的无效转换
【问题讨论】:
标签: xcode asynchronous error-handling swift2 xcode7-beta3