title: How to filter plist arrays with boolean key value in swift
body: <p>I am using this code to filter for certain strings in my plist array:</p>
  
  <pre><code>func SearchC(){
      let pathMC = NSBundle.mainBundle().pathForResource("myPlistArray", ofType: "plist")
      let dictMC = NSDictionary(contentsOfFile: pathMC!)
      myPlistArray = dictMC!["Questions"]!.mutableCopy() as? Array
  
      if let questionArray = myPlistArray as? [[String:AnyObject]] {
          let answersC = questionArray.filter({
              if let correct = $0["CorrectAnswer"] as? String {
                  return correct.uppercaseString == "C"
              }
              return false
          })
          print("\(answersC)")
      }
  }
  </code></pre>
  
  <p>I now need to filter for items which have the boolean value of “YES”, or “NO”. I tweaked the code above and came up with the following:</p>
  
  <pre><code>func SearchYES(){
      let pathMC = NSBundle.mainBundle().pathForResource("myPlistArray", ofType: "plist")
      let dictMC = NSDictionary(contentsOfFile: pathMC!)
      myPlistArray = dictMC!["Questions"]!.mutableCopy() as? Array
  
      if let questionArray = myPlistArray as? [[String:AnyObject]] {
          let isFavorite = questionArray.filter({
              if let favorite = $0["isFavorite"] as? String {
                  return favorite.uppercaseString == "YES"
              }
              return false
          })
          print("\(isFavorite)")
      }
  }
  </code></pre>
  
  <p>BUT it’s not working. Does anyone know how to filter items which have a boolean key value of TRUE/YES?</p>