title: Check NSArray contain NSDictionary key in Swift?
body: <p>I have array of NSDictionary and i want check particular NSDictionary "key" present in NSArray or not.</p>
  
  <p>I tried</p>
  
  <pre><code>if let val = dict["key"] {
      if let x = val {
          println(x)
      } else {
          println("value is nil")
      }
  } else {
      println("key is not present in dict")
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>let arrayOfKeys = dictionary.allKeys
  if (arrayOfKeys.containsObject(yourKey)) {
  
  }
  else {
  }
  </code></pre>
  
  <p>but this is for individual array object. Also</p>
  
  <pre><code>if ([[dictionary allKeys] containsObject:key]) {
      // contains key
  }
  </code></pre>
  
  <p>This method for individual NSDictionary not for NSArray.</p>
  
  <p>Also</p>
  
  <pre><code>if readArray.contains(["A":1]) {                  ALToastView.toastInView(UIApplication.sharedApplication().keyWindow, withText: "Already added")
        }else{
             readArray.append(["A":0]
         }
  </code></pre>
  
  <p>This code will add again same key in array if change value for key "A" </p>
  
  <p>Ex. My array contain dictionary ["A":1] and i want to check key "A" is present or not?
  How do i check any key present in Array? Do i need to iterate array? Thanks in advance.</p>