JubeatPlus 3.9.11
Loading...
Searching...
No Matches
MusicPlaylistManager Class Reference

Manages the user's music playlists, persisting them to a property-list file. More...

#include <MusicPlaylistManager.h>

Inheritance diagram for MusicPlaylistManager:
Collaboration diagram for MusicPlaylistManager:

Instance Methods

(instancetype) - initWithFile:
 Initialises the manager and loads any playlists already stored at file.
(void) - synchronize
 Writes the current playlists back to the file, atomically.
(NSUInteger) - numberOfPlaylists
 Returns the number of playlists.
(nullable NSMutableDictionary *) - playlistAtIndex:
 Returns the playlist dictionary at index, or nil if out of range or malformed.
(NSUInteger) - indexOfPlaylist:
 Returns the index of playlist by identity, or NSNotFound .
(NSUInteger) - indexOfPlaylistWithIdentifier:
 Returns the index of the playlist whose identifier equals identifier.
(nullable NSString *) - nameOfPlaylistAtIndex:
 Returns the display name of the playlist at index, or nil if out of range.
(nullable NSString *) - identifierOfPlaylistAtIndex:
 Returns the identifier of the playlist at index, or nil if out of range.
(BOOL) - setNameOfPlaylist:atIndex:
 Sets the display name of the playlist at index.
(BOOL) - addPlaylistWithName:
 Appends a new, empty playlist with the given display name.
(BOOL) - removePlaylistAtIndex:
 Removes the playlist at index.
(NSUInteger) - numberOfMusicInPlaylistAtIndex:
 Returns the number of music entries in the playlist at index.
(BOOL) - containsMusic:inPlaylistAtIndex:
 Tests whether the music identified by musicIdentifier is in the playlist at index.
(void) - addMusic:toPlaylistAtIndex:
 Adds the music identified by musicIdentifier to the playlist at index.
(BOOL) - removeMusic:fromPlaylistAtIndex:
 Removes the music identified by musicIdentifier from the playlist at index.

Properties

NSMutableArray * arrayPlaylist
 The playlists, each an NSMutableDictionary keyed by identifier, name, and music list.
NSString * filePath
 The property-list file the playlists are loaded from and written back to.

Detailed Description

Manages the user's music playlists, persisting them to a property-list file.

Each playlist is a mutable dictionary with three keys: a stable string identifier, a display name, and a mutable array of music identifiers (boxed NSUInteger values). The manager loads the array from a file on construction and writes it back on -synchronize .

Method Documentation

◆ addMusic:toPlaylistAtIndex:

- (void) addMusic: (NSUInteger) musicIdentifier
toPlaylistAtIndex: (NSUInteger) index 

Adds the music identified by musicIdentifier to the playlist at index.

Creates the music list if the playlist has none yet, and does nothing if the music is already present or musicIdentifier is 0 .

Parameters
musicIdentifierThe music identifier.
indexThe playlist index.
Ghidra address:
0x165858

◆ addPlaylistWithName:

- (BOOL) addPlaylistWithName: (nonnull NSString *) name

Appends a new, empty playlist with the given display name.

Mints a stable identifier and stores a playlist with an empty music list.

Parameters
nameThe display name; an empty name is rejected.
Returns
YES if name is non-empty and the playlist was added, NO otherwise.
Ghidra address:
0x1652e4

◆ containsMusic:inPlaylistAtIndex:

- (BOOL) containsMusic: (NSUInteger) musicIdentifier
inPlaylistAtIndex: (NSUInteger) index 

Tests whether the music identified by musicIdentifier is in the playlist at index.

Parameters
musicIdentifierThe music identifier; 0 is treated as absent.
indexThe playlist index.
Returns
YES if present, NO otherwise.
Ghidra address:
0x16570c

◆ identifierOfPlaylistAtIndex:

- (NSString *) identifierOfPlaylistAtIndex: (NSUInteger) index

Returns the identifier of the playlist at index, or nil if out of range.

Parameters
indexThe playlist index.
Returns
The playlist's identifier, or nil when the index is out of range.
Ghidra address:
0x165144

◆ indexOfPlaylist:

- (NSUInteger) indexOfPlaylist: (nonnull NSDictionary *) playlist

Returns the index of playlist by identity, or NSNotFound .

Parameters
playlistThe playlist dictionary to search for.
Returns
The playlist's index, or NSNotFound when it is not present.
Ghidra address:
0x164e4c

◆ indexOfPlaylistWithIdentifier:

- (NSUInteger) indexOfPlaylistWithIdentifier: (nullable NSString *) identifier

Returns the index of the playlist whose identifier equals identifier.

Parameters
identifierThe playlist identifier to match.
Returns
The index, or NSNotFound if no playlist matches or identifier is nil .
Ghidra address:
0x164ec4

◆ initWithFile:

- (instancetype) initWithFile: (nonnull NSString *) file

Initialises the manager and loads any playlists already stored at file.

Seeds an empty mutable array, remembers a copy of the path, then reads the file as an array of dictionaries. Each element that is a dictionary carrying all three keys is normalised into a fresh mutable dictionary and appended; malformed elements are skipped.

Parameters
fileThe property-list path to load from and later synchronise to.
Returns
The initialised manager, or nil if [super init] fails.
Ghidra address:
0x164804

◆ nameOfPlaylistAtIndex:

- (NSString *) nameOfPlaylistAtIndex: (NSUInteger) index

Returns the display name of the playlist at index, or nil if out of range.

Parameters
indexThe playlist index.
Returns
The playlist's display name, or nil when the index is out of range.
Ghidra address:
0x165068

◆ numberOfMusicInPlaylistAtIndex:

- (NSUInteger) numberOfMusicInPlaylistAtIndex: (NSUInteger) index

Returns the number of music entries in the playlist at index.

Parameters
indexThe playlist index.
Returns
The count, or 0 if the index is out of range or the playlist has no music list.
Ghidra address:
0x165608

◆ numberOfPlaylists

- (NSUInteger) numberOfPlaylists

Returns the number of playlists.

Returns
The playlist count.
Ghidra address:
0x164c74

◆ playlistAtIndex:

- (NSMutableDictionary *) playlistAtIndex: (NSUInteger) index

Returns the playlist dictionary at index, or nil if out of range or malformed.

The element is returned only when it is a dictionary carrying all three keys.

Parameters
indexThe playlist index.
Returns
The playlist dictionary, or nil .
Ghidra address:
0x164cc0

◆ removeMusic:fromPlaylistAtIndex:

- (BOOL) removeMusic: (NSUInteger) musicIdentifier
fromPlaylistAtIndex: (NSUInteger) index 

Removes the music identified by musicIdentifier from the playlist at index.

Parameters
musicIdentifierThe music identifier; 0 is treated as absent.
indexThe playlist index.
Returns
YES if the index was in range, NO otherwise.
Ghidra address:
0x1659f0

◆ removePlaylistAtIndex:

- (BOOL) removePlaylistAtIndex: (NSUInteger) index

Removes the playlist at index.

Parameters
indexThe playlist index.
Returns
YES if the index was in range, NO otherwise.
Ghidra address:
0x165560

◆ setNameOfPlaylist:atIndex:

- (BOOL) setNameOfPlaylist: (nonnull NSString *) name
atIndex: (NSUInteger) index 

Sets the display name of the playlist at index.

Parameters
nameThe new name; an empty name is rejected.
indexThe playlist index.
Returns
YES if name is non-empty (whether or not the index was in range), NO otherwise.
Ghidra address:
0x165220

◆ synchronize

- (void) synchronize

Writes the current playlists back to the file, atomically.

Ghidra address:
0x164c00

The documentation for this class was generated from the following files: