O'Reilly logo

RestKit for iOS by Taras Kalapun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Paginating results

If our web service returns a collection of items and their number is quite high, it can be a good idea to paginate them showing a user no more than, let's say, 20 of them in a page. Of course to use this method, your server needs to support this functionality.

RestKit provides an RKPaginator class for such use cases. Currently, it supports only web servers that respond pagination information as part of JSON/XML of the content, for example:

{
  "pagination": { 
      "per_page": 10, 
      "total_pages": 25, 
      "total_objects": 250 
  },
  "articles": [ 
    // Array of articles 
  ]
}

Instances of RKPaginator will start a HTTP GET request to remote the web service and retrieve paginated collections of mappable data. Paginators rely on RKObjectMappingProvider ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required