EDIT: is this answer still valid?
In essence: iOS loads only the relevant cells - so it does lazy loading automatically
I would like to optimise the loading of a UITableViewController following the result of an API call to a web-service. To solve this I need to be able to load only a certain number of rows in a UITableViewController.
Here is my current strategy / understanding:
- The API call will retrieve the list of data available.
- The data is locally stored
- A notification is sent to UITableViewController warning the view controller to refresh the data
- At this point I would like to either refresh the relevant cells or to create a list of cells based on the data. Here is where I need most of your help (see below).
In order to do so I think I need to solve the following problem:
Loading table view partially (lazy loading):
I would load only the section of the table that is visible by the user plus another bit. How can be this made?
The function below normally uses the count of the data available... can we use somehow a lazy loading approach on this (e.g. loading only 20 rows and not 200?)?
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return myarray.count
}
Any help?