Swift compiler error: cannot call 'lockForConfiguration' using argument list of type '(() -> ())'

This is Swift 2. I can not find anything on this. I get an 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) } 
+7
ios swift avfoundation avcapturesession
source share
3 answers

In Swift 2, the lockForConfiguration method takes no arguments, but may instead raise an NSError . You must wrap it in a do - try - catch try .

 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() 
+10
source share

You can try this line of code:

 device.lockForConfiguration(nil) 
0
source share

Shouldn't it be?

 if let device = captureDevice { device.lockForConfiguration(nil) device.videoZoomFactor = 1.0 + CGFloat(ratioValue) device.unlockForConfiguration() print(ratioValue) } 
0
source share

All Articles