binary operator '==' cannot be applied to operands of type 'String!' and '[String]' in Swift 2 Xcode 7 -
i have developed following code , it's working fine:
if metadataobj.type == avmetadataobjecttypeqrcode { //the code... }
now, metadataobj.type
equal array of string following:
let barcodetypes = [avmetadataobjecttypeqrcode, avmetadataobjecttypeazteccode ] if metadataobj.type == barcodetypes { //the code... }
i following error when use new code:
binary operator '==' cannot applied operands of type 'string!' , '[string]'
any suggestions? in advance
you can't compare string , array of strings, can use contains
:
if barcodetypes.contains(metadataobj.type)