title: Pagination with "data display limit" per page using UITableView
body: <p>I have some <code>data</code> coming from an <code>API</code>, in the following structure:</p>
  <pre><code>{
      &quot;AssetType&quot;: &quot;Watch&quot;,
      &quot;checkDate&quot;: &quot;2020-08-22&quot;,
      &quot;totalCount&quot;: 31,
      &quot;hasMore&quot;: true,
      &quot;skip&quot;: 10,
      &quot;items&quot;: [
          {
              &quot;id&quot;: &quot;150&quot;,
              &quot;name&quot;: &quot;Rolex&quot;,
              &quot;includeExtraParts&quot;: 0,
              &quot;package&quot;: &quot;box&quot;,
              &quot;unit&quot;: &quot;g&quot;,
              &quot;manufacture&quot;: null,
              &quot;totalPrice&quot;: 1738.04310497
          },
         ... ..
      ]
  }
  </code></pre>
  <p>I have parsed and displayed the data in my <code>UITableView</code> so far, and I want to fetch more data while <code>hasMore</code> flag is <code>true</code> and want to display the <code>data</code> of 10 counts per <code>fetch</code> in my <code>UITableView</code> till the <code>hasMore</code> flag becomes <code>false</code>..</p>
  <p>However, I can only <code>fetch</code> and display 10 counts of parsed data inside my <code>UITableView</code>..
  How can I properly implement the <code>data pagination</code> in order to achieve what I am trying to accomplish?</p>
  <p>here is what I have tried so far and it is NOT working properly and NOT invoking the <code>pagination</code> effect at all:</p>
  <p>Inside <code>viewDidLoad()</code>:</p>
  <pre><code> ApiCaller.getData(token: token, dataID: dataID, skip: skip, completion: { (response) in
      self.total = response.totalCount
      self.hasMore = response.hasMore
      self.skip = response.skip
      if self.skip &lt; response.totalCount &amp;&amp; response.hasMore == true {
          self.data = response.items
          
      }  else {
          return
      }
      self.tableVIew.reloadData()
  })
  
  </code></pre>
  <p>and my <code>func loadMore()</code> logic:</p>
  <pre><code>  func loadMore() {
          if (self.hasMore == false) {
              return
          } else {
              DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                  //calls the Api caller func inside viewDidLoad()
                  self.getData()
              }
              
          }
      }
  </code></pre>
  <p>and finally, inside <code>UITableViewDelegate</code>, I did/ called it like this:</p>
  <pre><code>
      func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
          
          if (self.hasMore == false) || (self.data.count == 0) {
              return
          }
          
          if indexPath.row == self.data.count - 3 {
              loadMore()
          }        
      }
  </code></pre>
  <p>and it is not working. Can anyone help me through this logic, please?</p>