Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift compiler error: Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'

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)
    }
like image 615
Matt Bettinson Avatar asked Sep 12 '15 23:09

Matt Bettinson


1 Answers

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()
like image 96
hennes Avatar answered Dec 01 '22 00:12

hennes