title: Remove complete element from Array Swift
body: <p>Im reading documents from firebase and putting them into an Array. The output of my array is:</p>
  
  <blockquote>
    <p>[MainApp.Message(name: Optional("Bluesona"), userId:
    Optional("7epbTeafCAS51ctDxWWt0xIAWN03"), msg: Optional(""), creatAt:
    Optional(1535028200082), latitude: Optional("0.00"), longitude:
    Optional("0.00")), MainApp.Message(name: Optional("Oliver"), userId:
    Optional("7epbTeafCAS51ctDxWWt0xIAWN03"), msg: Optional(""), creatAt:
    Optional(1537440120260), latitude: Optional("54.976663"), longitude:
    Optional("-7.732037")), MainApp.Message(name: Optional("Oliver"),
    userId: Optional("7epbTeafCAS51ctDxWWt0xIAWN03"), msg: Optional(""),
    creatAt: Optional(1537639139566), latitude: Optional("54.976726"),
    longitude: Optional("-7.731986"))]</p>
  </blockquote>
  
  <p>How can I then manipulate my array to only display items which have name "Bluesona"? </p>
  
  <p>Here is the code where I'm creating my array</p>
  
  <pre><code>    firebaseDB.collection("message").document(key).collection("messages").getDocuments() { (querySnapshot, err) in
          if let err = err {
              print("Error getting documents: \(err)")
          }
          else {
              self.dataArr.removeAll()
              for document in querySnapshot!.documents {
                  print("\(document.documentID) =&gt; \(document.data())")
                  let msgdata = document.data() as! [String:Any]
                  var msgObj = Message()
                  if let name = msgdata["name"] as? String {
  
                      msgObj.name = name
                  }
  
                  if let latitude = msgdata["latitude"] as? String {
  
                      msgObj.latitude = latitude
                  }
                  if let long = msgdata["longitude"] as? String {
  
                      msgObj.longitude = long
                  }
  
                  if let uid = msgdata["userId"] as? String {
  
                      msgObj.userId = uid
                  }
                  if let time = msgdata["createdAt"] as? Int {
  
                      msgObj.creatAt = time
                  }
                  self.dataArr.append(msgObj)
                  //                    self.dataArr.append(document.data() as [String:Any])
  
              }
              self.dataArr = self.dataArr.sorted(by: {$0.creatAt &lt; $1.creatAt })
              self.tblMessage.reloadData()
              if self.dataArr.count &lt; 1 {
                  print("No Messages")
              }
              else{
              //self.tblMessage.scrollToRow(at: IndexPath(row: self.dataArr.count - 1, section: 0), at: .bottom, animated: true)
              print(self.dataArr)
              }
              }
      }
  </code></pre>