Learn Courses My Dashboard

OR Code Scanning

I wanted help with the code scanning here. I don’t understand why it wouldn’t print the value for ‘code’ in the console. I am using scannerCode for this project.

import CodeScanner
import SwiftUI

struct ContentView: View {

@State private var showingScanner = false
@State var scannedCode = "Scan to get a QR Code"

var body: some View {
    VStack {
        Button(action: {
            self.showingScanner = true
        }) {
            Image(systemName: "qrcode")
                .frame(width: 32, height: 32)
        .sheet(isPresented: $showingScanner) {
            CodeScannerView(codeTypes: [.qr], simulatedData: "PPQQ") { result in
                 switch result {
                 case .success(let code):
                     self.scannedCode = String(code)
                 case .failure(let error):
                 self.showingScanner = false


struct ContentView_Previews: PreviewProvider {
static var previews: some View {

You can’t set a scannedResult equal to a String on line 33

If you put a breakpoint there, at print(code) what shows up?