title: Ios Swift : Remove duplicates in an array of images
body: <p>I have an array of images. User can add other images to this array picking from photo gallery. So when ever they add, I want check if that image is already present and if present, I need to skip adding that.</p>
  
  <p>I tried below But does not work on Image array</p>
  
  <pre><code>extension Array where Element : Equatable
  {
      mutating func GetDifAryFnc()
      {
          var DifAryVar:[Element] = []
          for IdxVal in self
          {
              if !DifAryVar.contains( IdxVal )
              {
                  DifAryVar.append( IdxVal )
              }
          }
          self = DifAryVar
      }
  }
  </code></pre>
  
  <p>and Tried This</p>
  
  <pre><code>class func GetDifImjAryFnc(ImjAryPsgVar: [UIImage]) -&gt; [UIImage]
  {
      var DifAryVar = [UIImage]()
      for IdxVal in ImjAryPsgVar
      {
          if !DifAryVar.contains( IdxVal )
          {
              DifAryVar.append( IdxVal )
          }
      }
  
      return DifAryVar
  }
  </code></pre>