SPTPlaylistList Class Reference
| Inherits from | SPTListPage : NSObject |
| Declared in | SPTPlaylistList.h |
Overview
This class represents a user’s list of playlists, and also contains methods for listing and creating new playlists on behalf of a user.
API Docs: https://developer.spotify.com/web-api/playlist-endpoints/
API Console: https://developer.spotify.com/web-api/console/playlists/
Playlist Guide: https://developer.spotify.com/web-api/working-with-playlists/
Tasks
Creating playlists
Listing a user's playlists
Playlist listing request creation methods
-
+ createRequestForCreatingPlaylistWithName:forUser:withPublicFlag:accessToken:error: -
+ createRequestForGettingPlaylistsForUser:withAccessToken:error:
Parsers / Deserializers
Class Methods
createPlaylistWithName:forUser:publicFlag:accessToken:callback:
Create a new playlist and add it to the this playlist list.
+ (void)createPlaylistWithName:(NSString *)name forUser:(NSString *)username publicFlag:(BOOL)isPublic accessToken:(NSString *)accessToken callback:(SPTPlaylistCreationCallback)blockParameters
- name
The name of the newly-created playlist.
- username
The user to create the playlist for. (Needs to be the currently authenticated user)
- isPublic
Whether the newly-created playlist is public.
- accessToken
An authenticated access token. Must be valid and authorized with the
playlist-modify-publicorplaylist-modify-privatescope as necessary.
- block
The callback block to be fired when playlist creation is completed (or fails).
Discussion
Declared In
SPTPlaylistList.hcreateRequestForCreatingPlaylistWithName:forUser:withPublicFlag:accessToken:error:
Create a request for creating a new playlist and add it to the current users' playlists.
+ (NSURLRequest *)createRequestForCreatingPlaylistWithName:(NSString *)name forUser:(NSString *)username withPublicFlag:(BOOL)isPublic accessToken:(NSString *)accessToken error:(NSError **)errorParameters
- name
The name of the newly-created playlist.
- username
The username of the user to create the playlist for. (Must be the current user)
- isPublic
Whether the newly-created playlist is public.
- accessToken
An authenticated access token. Must be valid and authorized with the
playlist-modify-publicorplaylist-modify-privatescope as necessary.
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Discussion
Declared In
SPTPlaylistList.hcreateRequestForGettingPlaylistsForUser:withAccessToken:error:
Get the a user’s playlist list.
+ (NSURLRequest *)createRequestForGettingPlaylistsForUser:(NSString *)username withAccessToken:(NSString *)accessToken error:(NSError **)errorParameters
- username
The username of the user to get playlists for.
- accessToken
An authenticated access token. Must be valid and authorized with the unspecified or
playlist-read-privatescope as necessary.
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Discussion
Example:
// Getting the first two pages of a playlists for a user
NSURLRequest *playlistrequest = [SPTPlaylistList createRequestForGettingPlaylistsForUser:@"possan" withAccessToken:accessToken error:nil];
[[SPTRequest sharedHandler] performRequest:playlistrequest callback:^(NSError *error, NSURLResponse *response, NSData *data) {
if (error != nil) { Handle error }
SPTPlaylistList *playlists = [SPTPlaylistList playlistListFromData:data withResponse:response error:nil];
NSLog(@"Got possan's playlists, first page: %@", playlists);
NSURLRequest *playlistrequest2 = [playlists createRequestForNextPageWithAccessToken:accessToken error:nil];
[[SPTRequest sharedHandler] performRequest:playlistrequest2 callback:^(NSError *error2, NSURLResponse *response2, NSData *data2) {
if (error2 != nil) { Handle error }
SPTPlaylistList *playlists2 = [SPTPlaylistList playlistListFromData:data2 withResponse:response2 error:nil];
NSLog(@"Got possan's playlists, second page: %@", playlists2);
}];
}];
See: https://developer.spotify.com/web-api/get-list-users-playlists/
Declared In
SPTPlaylistList.hplaylistListFromData:withResponse:error:
Parse the response of an API call into an SPTPlaylistList object
+ (instancetype)playlistListFromData:(NSData *)data withResponse:(NSURLResponse *)response error:(NSError **)errorParameters
- data
The API response data
- response
The API response object
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Declared In
SPTPlaylistList.hplaylistListFromDecodedJSON:error:
Parse a decoded JSON object into an SPTPlaylistList object
+ (instancetype)playlistListFromDecodedJSON:(id)decodedObject error:(NSError **)errorParameters
- decodedObject
The decoded JSON object
- error
An optional pointer to an
NSErrorthat will receive the error code if operation failed.
Declared In
SPTPlaylistList.hplaylistsForUser:withAccessToken:callback:
Get the a user’s playlist list.
+ (void)playlistsForUser:(NSString *)username withAccessToken:(NSString *)accessToken callback:(SPTRequestCallback)blockParameters
- username
The username of the user to get playlists for.
- accessToken
An authenticated access token. Must be valid and authorized with the unspecified or
playlist-read-privatescope as necessary.
- block
The block to be called when the operation is complete. The block will pass an
SPTPlaylistListobject on success, otherwise an error.
Discussion
See: https://developer.spotify.com/web-api/get-list-users-playlists/
Declared In
SPTPlaylistList.h