title: UITableView Pagination - Bottom Refresh to Load New Data in Swift
body: <p>I am trying to implement loading data from my backend with pagination. I have seen this, but it loads all the data, all then time. Is this the right way or am I doing something wrong?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell{
      let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
  
      print(indexPath.row)
  
      if (indexPath.row + 1 &lt; self.TotalRowsWithPages) {
          cell.textLabel?.text = "\(self.myarray!.[indexPath.row].body)"
      } else {
  
          cell.textLabel?.text = "Loading more data...";
  
          // User has scrolled to the bottom of the list of available data so simulate loading some more if we aren't already
          if (!self.isLoading) {
              self.isLoading = true;
              self.TotalRowsWithPages = self.TotalRowsWithPages + self.PageSize
              self.getmoredata()
          }
      }
  
      return cell
  }
  </code></pre>