Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

Paginate return results record sets

Within the Mobile SDK, when interacting with data from a ServiceNow instance through a REST endpoint using the NowTableService, you can create a Paginator object that enables you to iterate over the records in the return results.

You typically use paginated return results to provide infinite scroll capabilities for table records presented inside a UITableView, a UICollectionView (UIKit), or a List (SwiftUI), or to simplify page iteration of results in general.

The NowTableService class provides two methods for creating a Paginator object that contains the return results from a REST endpoint call:

The paginator type is determined by the Generics and the compiler type inference.

In the following example, the compiler infers that service.paginator(…) returns a paginator of type Paginator<[User]>, a paginator that publishes a collection of users, such as, Codable User structures, through its Combine publisher.

let paginator: Paginator<[User]> = service.paginator(from: "sys_user", path: "result")

After obtaining a Paginator object, subscribe to its publisher to start receiving data.

paginator.publisher
  .subscribe(on: DispatchQueue.global())
  .receive(on: DispatchQueue.main)
  .sink { ... }
  .store(in: &subscriptions)

The returned Paginator object provides the following methods that enable you to page through the returned records:

  • first()
  • last()
  • next()
  • previous()
  • reset()

Note: Some Paginator methods may throw an exception, such as when there are no more pages to fetch.

In addition, the Paginator object provides properties that enable you to obtain insights into the paginated data. For additional details on these properties and the available methods, see [Paginator API - iOS](../cllent-mobile-api-reference/PaginatorIOSAPI.md).