Search code examples
ioscamerabarcodescanning

When I use setMetadataObjectTypes: to load the type of the scanning barcode, I would like to set severals types (code39, code128, etc...)


I wrote this code for my app that uses the camera to scan barcodes:

[captureMetadataOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeCode128Code/\*AVMetadataObjectTypeCode39Code\*/]];

I would like to know how it is possible to write the fact that the setMetadataObjectTypes can handle two types of barcode: the barcodes code39 and code128?


Solution

  • Okay, I think I finally found the good way to write it :

            [captureMetadataOutput 
             setMetadataObjectTypes:
             @[AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeCode39Code]
    ];
    

    or

        [captureMetadataOutput
         setMetadataObjectTypes:
         [NSArray arrayWithObjects:
          AVMetadataObjectTypeCode128Code, 
          AVMetadataObjectTypeCode39Code,
         nil]];
    

    Hope it helps.