Latest 2.0.1
License MIT
Platforms ios 8.0



PagingDataController is a library for implementing loading data by page (pagination) easily. It provides a short setup via few lines of code. You will not need to worry about page management, when to load the next page’s data, and so on.

PagingDataControllerExtension is built with SVPullToRefresh. So you do not have to manually add controls. But you can customize everything if you want.

Pull to refresh
Load more data next page


  • iOS 8.0+
  • Xcode 8.3+
  • Swift 3.1+


PagingDataControllerExtension is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "PagingDataControllerExtension"

How it works?

Provider is a component which handles loading data by page. A list of objects or error will be returned once it is finished in processing.

DataSource keeps all of data which loaded by provider and arranges them in order of page.

A controller which implements PagingDataController includes a provider and a dataSource itself. While dataSource is injected automatically, provider needs to be declared explicit.


  1. Create a new project.
  2. In ViewController.swift, add a tableView or collectionView to display list of items.
  3. Create Provider:

import UIKit
import PagingDataController
import Alamofire

struct GithubUsersProvider: PagingProviderProtocol {

    //custom pageSize here
    var pageSize: Int = 36

    func loadData(parameters: AnyObject?, page: Int, completion: (([Dictionary<String, AnyObject>], Error?) -> ())?) {

        let apiPath = ""
        Alamofire.request(apiPath, method: .get).responseJSON { (response) in
            var error: Error? = response.result.error
            var result: [[String: AnyObject]] = []

            defer {
                completion?(result, error)

            guard let data = (response.result.value as? [String: AnyObject]) else {
            result = data["items"] as! [[String: AnyObject]]

  1. In ViewController.swift, Implement the methods of UITableViewDataSource or UICollectionViewDataSource to render data, make it conforms protocol PagingControllerProtocol
//Provider definition
lazy var provider = GithubUsersProvider()

Copy this method and put it below viewDidLoad():

override func viewDidFinishLayout() {
  • To custom parameters, implement this method parametersForPage(_:)
  • To error handling, implement this method errorWarningForPage(_:)
  1. Build & Run to enjoy


NGUYEN CHI CONG, [email protected]


PagingDataControllerExtension is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "PagingDataController",
    "version": "2.0.1",
    "summary": "A Swift pattern to apply paging data to UIViewController",
    "swift_version": "4.2",
    "description": "Only configure some properties & your view controller will load data by page automatically.nMagic !!!",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "NGUYEN CHI CONG": "[email protected]"
    "source": {
        "git": "",
        "tag": "2.0.1"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "default_subspecs": "Default",
    "subspecs": [
            "name": "Default",
            "dependencies": {
                "PagingDataController/Core": [],
                "PagingDataController/UIExtension": []
            "name": "Core",
            "source_files": "PagingDataController/Core/**/*"
            "name": "UIExtension",
            "source_files": "PagingDataController/UIExtension/**/*",
            "dependencies": {
                "PagingDataController/Core": [],
                "SiFUtilities": [],
                "SVPullToRefresh": []

Pin It on Pinterest

Share This