title: Swift: Better way to remove a specific Object from an array?
body: <p>I'm trying to be more efficient with my code, but I'm having a brain fart. This code I wrote works great, and does exactly what I need it to do: It checks an array and removes an Object at an unknown Index. But I feel there is a better, more efficient way to write it. I went to Array.remove(at:) but that requires a known index. I'm getting into big O notation and don't know how to make this easier to process. Any ideas?</p>
  
  <pre><code> // create a new object array
   var sort : [MyCustomObject] = []
  
  //iterate through my object array  
  
          for i in objectArray{
              if i === objectToRemove{
              }
              else{
                  sort.append(i)
              }
          }
  
       // set old array to sort, which no longer has the unwanted object 
          self.objectArray = sort
  </code></pre>