SPTListPage Class Reference
| Inherits from | NSObject |
| Conforms to | SPTTrackProvider |
| Declared in | SPTListPage.h |
Overview
This class represents a page within a paginated list.
For the sake of conserving resources, lists that have the potential to be very large (such as search results, a playlist or album’s tracks, etc) are not delivered as a whole from the Spotify backend - instead, such lists are paginated. This class allows you to work with those pages.
API Model: https://developer.spotify.com/web-api/object-model/#paging-object
Tasks
Properties
-
rangeproperty -
totalListLengthproperty -
hasNextPageproperty -
hasPreviousPageproperty -
nextPageURLproperty -
previousPageURLproperty -
isCompleteproperty -
itemsproperty
API Request Factories
-
– createRequestForNextPageWithAccessToken:error: -
– createRequestForPreviousPageWithAccessToken:error:
API Response Parsers
-
+ listPageFromData:withResponse:expectingPartialChildren:rootObjectKey:error: -
+ listPageFromDecodedJSON:expectingPartialChildren:rootObjectKey:error:
Navigation and Manipulation
Properties
hasNextPage
Returns YES if there is at least one page in the source list after the receiver, otherwise NO.
@property (nonatomic, readonly) BOOL hasNextPageDeclared In
SPTListPage.hhasPreviousPage
Returns YES if there is at least one page in the source list before the receiver, otherwise NO.
@property (nonatomic, readonly) BOOL hasPreviousPageDeclared In
SPTListPage.hisComplete
Returns YES if the page contains every single item in the source list, otherwise NO.
@property (nonatomic, readonly) BOOL isCompleteDeclared In
SPTListPage.hitems
The items contained in the page the receiver represents.
@property (nonatomic, readonly, copy) NSArray *itemsDeclared In
SPTListPage.hnextPageURL
Returns the API url to the next page of items if it exist, otherwise nil.
@property (nonatomic, readonly, copy) NSURL *nextPageURLDeclared In
SPTListPage.hpreviousPageURL
Returns the API url to the previous page of items if it exist, otherwise nil.
@property (nonatomic, readonly, copy) NSURL *previousPageURLDeclared In
SPTListPage.hClass Methods
listPageFromData:withResponse:expectingPartialChildren:rootObjectKey:error:
Create a SPTListPage from a API response
+ (instancetype)listPageFromData:(NSData *)data withResponse:(NSURLResponse *)response expectingPartialChildren:(BOOL)hasPartialChildren rootObjectKey:(NSString *)rootObjectKey error:(NSError **)errorParameters
- data
The API Response data
- response
The API Response object
- hasPartialChildren
True if api response provides partial entities, not full ones.
- rootObjectKey
The name of the entity with the actual content, or
nilif the same as the root.
- error
An optional pointer to a
NSErrorobject that will be set if an error occured.
Return Value
A SPTListPage, or nil if an error occured.
Declared In
SPTListPage.hlistPageFromDecodedJSON:expectingPartialChildren:rootObjectKey:error:
Create a SPTListPage from a decoded JSON structure
+ (instancetype)listPageFromDecodedJSON:(id)decodedObject expectingPartialChildren:(BOOL)hasPartialChildren rootObjectKey:(NSString *)rootObjectKey error:(NSError **)errorParameters
- decodedObject
The JSON root entity
- hasPartialChildren
True if api response provides partial entities, not full ones.
- rootObjectKey
The name of the entity with the actual content, or
nilif the same as the root.
- error
An optional pointer to a
NSErrorobject that will be set if an error occured.
Return Value
A SPTListPage, or nil if an error occured.
Declared In
SPTListPage.hInstance Methods
createRequestForNextPageWithAccessToken:error:
Create a request for fetching the next page in the source list.
- (NSURLRequest *)createRequestForNextPageWithAccessToken:(NSString *)accessToken error:(NSError **)errorParameters
- accessToken
An authenticated access token. Must be valid and authorized.
- error
An optional
NSErrorthat will be set if an error occured.
Declared In
SPTListPage.hcreateRequestForPreviousPageWithAccessToken:error:
Create a request for fetching the previous page in the source list.
- (NSURLRequest *)createRequestForPreviousPageWithAccessToken:(NSString *)accessToken error:(NSError **)errorParameters
- accessToken
An authenticated access token. Must be valid and authorized.
- error
An optional
NSErrorthat will be set if an error occured.
Declared In
SPTListPage.hpageByAppendingPage:
Create a new page by adding a page to the receiver.
- (instancetype)pageByAppendingPage:(SPTListPage *)nextPageParameters
- nextPage
The page to add to the receiver.
Return Value
A new SPTListPage containing the union of the receiver and nextPage.
Discussion
Warning: The added page must start immediately after the receiver - that is,
nextPage.range.location must equal self.range.location + self.range.length.
Declared In
SPTListPage.hrequestNextPageWithAccessToken:callback:
Request the next page in the source list.
- (void)requestNextPageWithAccessToken:(NSString *)accessToken callback:(SPTRequestCallback)blockParameters
- accessToken
An authenticated access token. Must be valid and authorized.
- block
The block to be called when the operation is complete. This block will pass an error if the operation failed, otherwise the next
SPTListPagein the source list.
Declared In
SPTListPage.hrequestPreviousPageWithAccessToken:callback:
Request the previous page in the source list.
- (void)requestPreviousPageWithAccessToken:(NSString *)accessToken callback:(SPTRequestCallback)blockParameters
- accessToken
An authenticated access token. Must be valid and authorized.
- block
The block to be called when the operation is complete. This block will pass an error if the operation failed, otherwise the previous
SPTListPagein the source list.
Declared In
SPTListPage.h