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.
-
patternURL
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 -
URL
Returns a complete RKURL to the paginated resource collection by interpolating the state of the paginator object against the resource
property -
delegate
The object that acts as the delegate of the receiving paginator.
property -
onDidLoadObjectsForPage
The block to invoke when the paginator has loaded a page of objects from the collection.
property -
onDidFailWithError
The block to invoke when the paginator has failed loading due to an error.
property -
configurationDelegate
The object that acts as the configuration delegate for RKObjectLoader instances built and utilized by the paginator.
property
Object Mapping Configuration
-
mappingProvider
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 -
objectStore
An object store for accessing Core Data. Required if the objects being paginated are stored into Core Data.
property
Pagination Metadata
-
perPage
The number of objects to load per page
property -
loaded
A Boolean value indicating if the paginator has loaded a page of objects
property -
currentPage
Returns the page number for the most recently loaded page of objects.
property -
pageCount
Returns the number of pages in the total resource collection.
property -
objectCount
Returns the total number of objects in the collection
property -
– hasPageCount
Returns a Boolean value indicating if the total number of pages in the collection is known by the paginator.
-
– hasObjectCount
Returns a Boolean value indicating if the total number of objects in the collection is known by the paginator.
-
– hasNextPage
Returns a Boolean value indicating if there is a next page in the collection.
-
– hasPreviousPage
Returns a Boolean value indicating if there is a previous page in the collection.
Paginator Actions
-
– loadNextPage
Loads the next page of data by incrementing the current page, constructing an object loader to fetch the data, and object mapping the results.
-
– loadPreviousPage
Loads 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 *URL
Declared In
RKObjectPaginator.h
configurationDelegate
The object that acts as the configuration delegate for RKObjectLoader instances built and utilized by the paginator.
@property (nonatomic, assign) id<> configurationDelegate
Discussion
Default: nil
See Also
Declared In
RKObjectPaginator.h
currentPage
Returns the page number for the most recently loaded page of objects.
@property (nonatomic, readonly) NSUInteger currentPage
Return Value
The page number for the current page of objects.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded is NO.
Declared In
RKObjectPaginator.h
delegate
The object that acts as the delegate of the receiving paginator.
@property (nonatomic, assign) id<> delegate
Declared In
RKObjectPaginator.h
loaded
A Boolean value indicating if the paginator has loaded a page of objects
@property (nonatomic, readonly, getter=isLoaded) BOOL loaded
Return Value
YES when the paginator has loaded a page of objects
Declared In
RKObjectPaginator.h
mappingProvider
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 *mappingProvider
Declared In
RKObjectPaginator.h
objectCount
Returns the total number of objects in the collection
@property (nonatomic, readonly) NSUInteger objectCount
Return Value
A count of the number of objects in the resource collection.
Exceptions
- NSInternalInconsistencyException
Raised if hasObjectCount is NO.
Declared In
RKObjectPaginator.h
objectStore
An object store for accessing Core Data. Required if the objects being paginated are stored into Core Data.
@property (nonatomic, retain) RKManagedObjectStore *objectStore
Declared In
RKObjectPaginator.h
onDidFailWithError
The block to invoke when the paginator has failed loading due to an error.
@property (nonatomic, copy) RKObjectPaginatorDidFailWithErrorBlock onDidFailWithError
Declared In
RKObjectPaginator.h
onDidLoadObjectsForPage
The block to invoke when the paginator has loaded a page of objects from the collection.
@property (nonatomic, copy) RKObjectPaginatorDidLoadObjectsForPageBlock onDidLoadObjectsForPage
Declared In
RKObjectPaginator.h
pageCount
Returns the number of pages in the total resource collection.
@property (nonatomic, readonly) NSUInteger pageCount
Return Value
A count of the number of pages in the resource collection.
Exceptions
- NSInternalInconsistencyException
Raised if hasPageCount is NO.
Declared In
RKObjectPaginator.h
patternURL
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 *patternURL
Discussion
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.h
Class Methods
paginatorWithPatternURL:mappingProvider:
Creates and returns a RKObjectPaginator object with the a provided patternURL and mappingProvider.
+ (id)paginatorWithPatternURL:(RKURL *)patternURL mappingProvider:(RKObjectMappingProvider *)mappingProvider
Parameters
- 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.h
Instance Methods
hasNextPage
Returns a Boolean value indicating if there is a next page in the collection.
- (BOOL)hasNextPage
Return Value
YES if there is a next page, otherwise NO.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded or hasPageCount is NO.
Declared In
RKObjectPaginator.h
hasObjectCount
Returns a Boolean value indicating if the total number of objects in the collection is known by the paginator.
- (BOOL)hasObjectCount
Return Value
YES if the paginator knows the number of objects in the paginated collection, otherwise NO.
Declared In
RKObjectPaginator.h
hasPageCount
Returns a Boolean value indicating if the total number of pages in the collection is known by the paginator.
- (BOOL)hasPageCount
Return Value
YES if the paginator knows the page count, otherwise NO
Declared In
RKObjectPaginator.h
hasPreviousPage
Returns a Boolean value indicating if there is a previous page in the collection.
- (BOOL)hasPreviousPage
Return Value
YES if there is a previous page, otherwise NO.
Exceptions
- NSInternalInconsistencyException
Raised if isLoaded is NO.
Declared In
RKObjectPaginator.h
initWithPatternURL:mappingProvider:
Initializes a RKObjectPaginator object with the a provided patternURL and mappingProvider.
- (id)initWithPatternURL:(RKURL *)patternURL mappingProvider:(RKObjectMappingProvider *)mappingProvider
Parameters
- 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.h
loadNextPage
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)loadNextPage
Declared In
RKObjectPaginator.h