This is Swift 2. I can't seem to find anything on this. I am getting the error
Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'
On the second line here.
if let device = captureDevice {
device.lockForConfiguration() {
device.videoZoomFactor = 1.0 + CGFloat(ratioValue)
device.unlockForConfiguration()
}
print(ratioValue)
}
In Swift 2 the method lockForConfiguration
doesn't take any arguments but instead can throw an NSError
. You should wrap it in a do
-try
-catch
statement.
do {
try device.lockForConfiguration()
} catch {
// handle error
return
}
// When this point is reached, we can be sure that the locking succeeded
device.videoZoomFactor = 1.0 + CGFloat(ratioValue)
device.unlockForConfiguration()