title: Firestore: How to get the object data from firestore in IOS (Swift) and display it in tableview
body: <p>I have a structure in firestore database like  object form. I need to retrieve the data from firestore and display it in tablebview in swift</p>
  
  <pre><code>-
  
  collection//users
          -authid
         - collection//Split
           - auth id
           - collection//SentInvitations
             -automatic id
               -Invitee(i)(object)
                  .name:bnnn
                  .phonenumber:567788
                  .amount:123
              - Invitee(2)
                  .name:aaaa
                  .phonenumber:987654321
                  .amount:198
  </code></pre>
  
  <p>where i = no.of invitees
  Now I need to retrieve these all invitees and display into table view</p>
  
  <p><strong><em>Code I tried to retrieve the data from firestore</em></strong> </p>
  
  <pre><code>func loadData(){
      let authid = Auth.auth().currentUser?.uid
     let docRef =  db.collection("deyaPayUsers").document(authid!).collection("Split").document(authid!).collection("SentInvitations").document(senderautoid!)
          docRef.getDocument { (document, error) in
                          if let city = document.flatMap({
                              $0.data().flatMap({ (data) in
                                  return Invite(dictionary: data)
                              })
                          }) {
                              print("City: \(city)")
                          } else {
                              print("Document does not exist")
                          }
                      }
  
      }
  </code></pre>
  
  <p><strong><em>and my model class Invite</em></strong></p>
  
  <pre><code>import Foundation
  import FirebaseFirestore
  
  protocol DocumentSerializable2
  {
      init?(dictionary:[String:Any])
  }
  struct Invite {
      var PhoneNumber:Int
      var Amount:Int
      //var Status:String
      var dictionary:[String:Any]{
          return [
              "PhoneNumber":PhoneNumber,
              "Amount":Amount,
              ]
      }
  }
      extension  Invite : DocumentSerializable2{
      init?(dictionary: [String:Any]){
          guard let amount = dictionary["Amount"] as? Int,
              let phonenumber = dictionary["PhoneNumber"] as? Int else { return nil}
          self.init(PhoneNumber:phonenumber, Amount:amount)
  
          }
      }
  </code></pre>
  
  <p>when I execute this code it does to the else condition document does not exist but in firestore it contains the document. To get these there is any  other method to solve <a href="https://i.stack.imgur.com/mTcwi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mTcwi.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/auG2r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/auG2r.png" alt="enter image description here"></a></p>