-1

I’m trying to zoom in if a button gets pressed. Apple writes in its Documentation that I have to call lockForConfiguration() and unlockForConfiguration() when im changing the videoZoomFactor’s value. But I’m unsure if this is the right way to implement.

@IBAction func zoomBtnPressed(_ sender: UIButton) {

        do {
            try captureDevice.lockForConfiguration()
        } catch {
            print(error)
        }

        captureDevice.videoZoomFactor = 10

        do {
            try captureDevice.unlockForConfiguration()
        } catch {
            print(error)
        }

    }

For the unlockForConfiguration() I get two warnings.

⚠️ No calls to throwing functions occur within 'try' expression

⚠️ 'catch' block is unreachable because no errors are thrown in 'do' block

Daniel
  • 568
  • 3
  • 15

1 Answers1

0

Welcome!

unlockForConfiguration is not a throwing function. You don't need to do { try ... } catch { ... } around it.

Frank Rupprecht
  • 9,191
  • 31
  • 56