我是 Swift/iOS 开发的新手,正在将 Swift 3.0 项目转换为 Swift 4.2 以支持更新的设备。
在此过程中,我收到以下错误:
无法将类型“[String]”的值分配给类型“[AVMetadataObject.ObjectType]?”
以下是引发错误的代码行:
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.