I am new to Swift/iOS development and am working on Converting a Swift 3.0 project to Swift 4.2 in order to support newer devices.
In the process I am getting the following error :
Cannot assign value of type '[String]' to type '[AVMetadataObject.ObjectType]?'
Below are the lines of code throwing the error:
let metadataOutput = AVCaptureMetadataOutput()
metadataOutput.metadataObjectTypes = [convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.upce),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.code39),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.code39Mod43),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.ean13),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.ean8),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.code93),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.code128),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.pdf417),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.aztec),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.interleaved2of5),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.itf14),
convertFromAVMetadataObjectObjectType(AVMetadataObject.ObjectType.dataMatrix)]// Support for AVMetadataObjectTypeQRCode / qr code is removed from the list.
The migrator helps at its best but sometimes the help is misleading.
You can populate the array just with the static members
metadataOutput.metadataObjectTypes = [.upce, .code39, .code39Mod43, .ean13, .ean8, .code93, .code128, .pdf417, .aztec, .interleaved2of5, .itf14, .dataMatrix]