条码的Code如何与数组码匹配?

How to match the Code of barcode with array codes?

我想要一个匹配的数组有代码 我已经匹配了一个代码,它可以正常工作 此代码运行良好

 let code = "code"

   if metadataObj.stringValue == code {

  println("the code is true")

    }else {

        println("the code is false") 

   }

但是当我尝试这段代码时

 var codes = ["a","b","c"]

   if metadataObj.stringValue == codes {
       println("the code is true")

        }else {

       println("the code is false") 
   }

出现这个问题 不能使用

类型的参数列表调用 ==

它适用于数组 var codes = ["a","b","c"] 但是当你放置分析数组时 JSON 本地文件不起作用

一个字符串不能等于一个数组

如果要测试字符串是否等于数组元素之一 然后使用 contains():

if contains(codes, metadataObj.stringValue) { ... }