Alk
Alk

Reputation: 5557

Cannot assign value type mismatch swift

I have the following code snippet.

 camera.onDeviceChange = { [weak self] (camera: LLSimpleCamera!, device: AVCaptureDevice!) -> Void in
      print("Device changed.")
 }

This used to work fine in Swift 2, but now I am getting the following error message:

Cannot assign value of type '(LLSimpleCamera!, AVCaptureDevice!) -> Void' to type '((LLSimpleCamera?, AVCaptureDevice?) -> Void)!'

Not really sure how to change this, I tried matching the type by changing the ! to optionals and then adding ! after the void, however this didn't work.

Upvotes: 1

Views: 405

Answers (1)

Bhavin Bhadani
Bhavin Bhadani

Reputation: 22374

Your error suggest type mismatch that means LLSimpleCamera! != LLSimpleCamera? .. there is no need to define type. .. you can use it something like

camera.onDeviceChange = { [weak self] (camera, device) -> Void in
   print("Device changed.")
}

Upvotes: 1

Related Questions