Open nahooni0511 opened 6 months ago
hey @nahooni0511 thanks for your PR, i would like to return the complete object, even if asserUrl or any other object property is absent, so we can match the Song / Album interfaces
interface Song {
url: string;
title: string;
album: string;
artist: string;
duration: number;
genre: string;
cover: string;
}
interface Album {
url: string;
album: string;
artist: string;
numberOfSongs: string;
cover: string;
}
You could use ternary operator for such case. i.e
[songDictionary setValue:(assetURL && assetURL.absoluteString) ? [NSString stringWithString:assetURL.absoluteString] : @"" forKey:@"url"];
Thanks again.
This commit introduces essential nil checks across the TurboSongs module to ensure stability and error handling for properties that might not always be present, such as the assetURL, title, albumTitle, and more. Notably, this update addresses a common scenario with Apple Music, where downloaded songs for offline use do not have an assetURL. By adding these checks, the module now safely handles such cases, preventing potential crashes and improving the user experience when working with local and downloaded media items. This enhancement is crucial for developers integrating with the Apple Music library, ensuring that their applications can gracefully handle a variety of media item states.
To reproduce the issue, follow these steps: Navigate to Apple Music, select a song, add it to your library, then select the song from within your library and download it for offline use. In this scenario, the song's
assetURL
may be absent, leading to the issue this pull request addresses.