RKObjectPaginator Class Reference
| Inherits from | NSObject |
| Declared in | RKObjectPaginator.h RKObjectPaginator.m |
Overview
Instances of RKObjectPaginator retrieve paginated collections of mappable data from remote systems via HTTP. Paginators perform GET requests and use a patterned URL to construct a full URL reflecting the state of the paginator. Paginators rely on an instance of RKObjectMappingProvider to determine how to perform object mapping on the retrieved data. Paginators can load Core Data backed models provided that an instance of RKManagedObjectStore is assigned to the paginator.
Tasks
Other Methods
-
+ paginatorWithPatternURL:mappingProvider:Creates and returns a RKObjectPaginator object with the a provided patternURL and mappingProvider.
-
– initWithPatternURL:mappingProvider:Initializes a RKObjectPaginator object with the a provided patternURL and mappingProvider.
-
patternURLA RKURL with a resource path pattern for building a complete URL from which to load the paginated resource collection. The patterned resource path will be evaluated against the state of the paginator object itself.
property -
URLReturns a complete RKURL to the paginated resource collection by interpolating the state of the paginator object against the resource
property -
delegateThe object that acts as the delegate of the receiving paginator.
property -
onDidLoadObjectsForPageThe block to invoke when the paginator has loaded a page of objects from the collection.
property -
onDidFailWithErrorThe block to invoke when the paginator has failed loading due to an error.
property -
configurationDelegateThe object that acts as the configuration delegate for RKObjectLoader instances built and utilized by the paginator.
property
Object Mapping Configuration
-
mappingProviderThe mapping provider to use when performing object mapping on the data loaded from the remote system. The provider will be assigned to the RKObjectLoader instance built to retrieve the paginated resource collection.
property -
objectStoreAn object store for accessing Core Data. Required if the objects being paginated are stored into Core Data.
property
Pagination Metadata
-
perPageThe number of objects to load per page
property -
loadedA Boolean value indicating if the paginator has loaded a page of objects
property -
currentPageReturns the page number for the most recently loaded page of objects.
property -
pageCountReturns the number of pages in the total resource collection.
property -
objectCountReturns the total number of objects in the collection
property -
– hasPageCountReturns a Boolean value indicating if the total number of pages in the collection is known by the paginator.
-
– hasObjectCountReturns a Boolean value indicating if the total number of objects in the collection is known by the paginator.
-
– hasNextPageReturns a Boolean value indicating if there is a next page in the collection.
-
– hasPreviousPageReturns a Boolean value indicating if there is a previous page in the collection.
Paginator Actions
-
– loadNextPageLoads the next page of data by incrementing the current page, constructing an object loader to fetch the data, and object mapping the results.
-
– loadPreviousPageLoads the previous page of data by decrementing the current page, constructing an object loader to fetch the data, and object mapping the results.
-
– loadPage:Loads a specific page of data by mutating the current page, constructing an object loader to fetch the data, and object mapping the results.
Properties
URL
Returns a complete RKURL to the paginated resource collection by interpolating the state of the paginator object against the resource
@property (nonatomic, readonly) RKURL *URLDeclared In
RKObjectPaginator.hconfigurationDelegate
The object that acts as the configuration delegate for RKObjectLoader instances built and utilized by the paginator.
@property (nonatomic, assign) id<> configurationDelegateDiscussion
Default: nil
See Also
Declared In
RKObjectPaginator.hcurrentPage
Returns the page number for the most recently loaded page of objects.
@property (nonatomic, readonly) NSUInteger currentPageReturn Value
The page number for the current page of objects.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded is NO.
Declared In
RKObjectPaginator.hdelegate
The object that acts as the delegate of the receiving paginator.
@property (nonatomic, assign) id<> delegateDeclared In
RKObjectPaginator.hloaded
A Boolean value indicating if the paginator has loaded a page of objects
@property (nonatomic, readonly, getter=isLoaded) BOOL loadedReturn Value
YES when the paginator has loaded a page of objects
Declared In
RKObjectPaginator.hmappingProvider
The mapping provider to use when performing object mapping on the data loaded from the remote system. The provider will be assigned to the RKObjectLoader instance built to retrieve the paginated resource collection.
@property (nonatomic, retain) RKObjectMappingProvider *mappingProviderDeclared In
RKObjectPaginator.hobjectCount
Returns the total number of objects in the collection
@property (nonatomic, readonly) NSUInteger objectCountReturn Value
A count of the number of objects in the resource collection.
Exceptions
- NSInternalInconsistencyException
Raised if hasObjectCount is NO.
Declared In
RKObjectPaginator.hobjectStore
An object store for accessing Core Data. Required if the objects being paginated are stored into Core Data.
@property (nonatomic, retain) RKManagedObjectStore *objectStoreDeclared In
RKObjectPaginator.honDidFailWithError
The block to invoke when the paginator has failed loading due to an error.
@property (nonatomic, copy) RKObjectPaginatorDidFailWithErrorBlock onDidFailWithErrorDeclared In
RKObjectPaginator.honDidLoadObjectsForPage
The block to invoke when the paginator has loaded a page of objects from the collection.
@property (nonatomic, copy) RKObjectPaginatorDidLoadObjectsForPageBlock onDidLoadObjectsForPageDeclared In
RKObjectPaginator.hpageCount
Returns the number of pages in the total resource collection.
@property (nonatomic, readonly) NSUInteger pageCountReturn Value
A count of the number of pages in the resource collection.
Exceptions
- NSInternalInconsistencyException
Raised if hasPageCount is NO.
Declared In
RKObjectPaginator.hpatternURL
A RKURL with a resource path pattern for building a complete URL from which to load the paginated resource collection. The patterned resource path will be evaluated against the state of the paginator object itself.
@property (nonatomic, copy) RKURL *patternURLDiscussion
For example, given a paginated collection of data at the /articles resource path, the patterned resource path may look like:
/articles?per_page=:perPage&page_number=:currentPage
When the pattern is evaluated against the state of the paginator, this will yield a complete resource path that can be used to load the specified page. Given a paginator configured with 100 objects per page and a current page number of 3, the resource path of the pagination URL would become:
/articles?per_page=100&page_number=3
Declared In
RKObjectPaginator.hClass Methods
paginatorWithPatternURL:mappingProvider:
Creates and returns a RKObjectPaginator object with the a provided patternURL and mappingProvider.
+ (id)paginatorWithPatternURL:(RKURL *)patternURL mappingProvider:(RKObjectMappingProvider *)mappingProviderParameters
- patternURL
A RKURL containing a dynamic pattern for constructing a URL to the paginated
resource collection.
- mappingProvider
An RKObjectMappingProvider containing object mapping configurations for mapping the
paginated resource collection.
Return Value
A paginator object initialized with patterned URL and mapping provider.
See Also
Declared In
RKObjectPaginator.hInstance Methods
hasNextPage
Returns a Boolean value indicating if there is a next page in the collection.
- (BOOL)hasNextPageReturn Value
YES if there is a next page, otherwise NO.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded or hasPageCount is NO.
Declared In
RKObjectPaginator.hhasObjectCount
Returns a Boolean value indicating if the total number of objects in the collection is known by the paginator.
- (BOOL)hasObjectCountReturn Value
YES if the paginator knows the number of objects in the paginated collection, otherwise NO.
Declared In
RKObjectPaginator.hhasPageCount
Returns a Boolean value indicating if the total number of pages in the collection is known by the paginator.
- (BOOL)hasPageCountReturn Value
YES if the paginator knows the page count, otherwise NO
Declared In
RKObjectPaginator.hhasPreviousPage
Returns a Boolean value indicating if there is a previous page in the collection.
- (BOOL)hasPreviousPageReturn Value
YES if there is a previous page, otherwise NO.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded is NO.
Declared In
RKObjectPaginator.hinitWithPatternURL:mappingProvider:
Initializes a RKObjectPaginator object with the a provided patternURL and mappingProvider.
- (id)initWithPatternURL:(RKURL *)patternURL mappingProvider:(RKObjectMappingProvider *)mappingProviderParameters
- patternURL
A RKURL containing a dynamic pattern for constructing a URL to the paginated resource collection.
- mappingProvider
An RKObjectMappingProvider containing object mapping configurations for mapping the paginated resource collection.
Return Value
The receiver, initialized with patterned URL and mapping provider.
See Also
Declared In
RKObjectPaginator.hloadNextPage
Loads the next page of data by incrementing the current page, constructing an object loader to fetch the data, and object mapping the results.
- (void)loadNextPageDeclared In
RKObjectPaginator.h