0

I have issues, i work with parse data base, and i have more then 200 data tables.

And more then 150 000 records. Now i have search bar which connect to table view.

My code to upload data from parse server in to table view:

searchBar.resignFirstResponder()
searchResult.removeAll(keepingCapacity: false)
answer.removeAll(keepingCapacity: false)
searchQuery.query.forEach { $0.whereKey("question", contains: searchBar.text) }
        searchQuery.query.forEach { (query) in
            query.findObjectsInBackground { (result, error) in
                if let objects = result {
                    for object in objects {
                        let question = object.object(forKey: "question") as! String
                        let answer = object.object(forKey: "answer1") as! String
                        self.answer.append(answer)
                        self.searchResult.append(question)
                    }
                    DispatchQueue.main.async {
                        self.tableView.reloadData()
                        self.resignFirstResponder()
                    }
                }
            }
        }

I have array of query which i stored at the separate module:

searchQuery.query

So my question is, when i come to the bottom table view, i want to load another function which will upload new data, how i can do this?

Andrew
  • 372
  • 2
  • 5
  • 25

1 Answers1

2

You want to use table view method for this . Basically this method is used for pagination purpose most of time.

func scrollViewDidScroll(_ scrollView: UIScrollView) {

    //If we reach the end of the table.
    if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
    {
        // Call method

        tableView.reloadData()
    }
}
Protocol
  • 1,696
  • 13
  • 30