Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:53:10+00:00 2026-06-17T05:53:10+00:00

I’m displaying a list of Spotify tracks in a table view in my application,

  • 0

I’m displaying a list of Spotify tracks in a table view in my application, and I’d like to download the cover art for the albums that these tracks belong to.

I’m logged in to CocoaLibSpotify, and I can play all the tracks, so that part is fine. What I can’t seem to get to work is the download of the cover art. I follow the code of the SimplePlayer project, with the exception that I store the SPTrack instances in a mutable dictionary (tracksDownladingForCoverArt), since there could be many tracks downloading cover art.

So, this is what I do:

[[SPSession sharedSession] trackForURL:nativeSpotifyURL callback:^(SPTrack *track) {
    if (track != nil) {

        [track addObserver:self forKeyPath:@"album.cover.spotifyURL" options:0 context:NULL];
        self.tracksDownloadingForCoverArt[nativeSpotifyURL] = track;

        [SPAsyncLoading waitUntilLoaded:track timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *tracks, NSArray *notLoadedTracks) {
            if ([tracks count] > 0) {
                // I don't believe I need to do anything here
            }
        }];
    }
}];

The observeValueForKeyPath:ofObject:change:context: is called once, with an old and new value of nil, but after that, nothing. However, if I follow SimplePlayer to the letter (i.e. have self.currentTrack instead of a dictionary) and register for the key path @”self.currentTrack.album.cover.spotifyURL”, the observerValue… method is called twice, once with nil and once with an actual value.

What am I missing? Oh, and I register for the spotifyURL rather than the image, so I can cache the image. That way, when the user quits the app and returns later, not all the images have to be reloaded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:53:11+00:00Added an answer on June 17, 2026 at 5:53 am

    This is intended behaviour — cover art isn’t loaded unless you explicitly ask for it to keep data usage down. To load all the cover art, you could do this…

    NSArray *tracksToGetArtFor = …; // Get some tracks;
    [SPAsyncLoading waitUntilLoaded:tracks timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedTracks, NSArray *notLoadedTracks) {
    
        NSArray *coverArts = [tracks valueForKey:@"album.cover"]; // Get an array of the track's covers
    
        [SPAsyncLoading waitUntilLoaded:coverArts timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedCovers, NSArray *notLoadedCovers) {
            NSLog(@"Number of covers that're loaded: %@:", @(loadedCovers.count));
        }];
    ]};
    

    You’ll likely want a larger timeout for loading a lot of covers, since they can be fairly big.

    Another approach if you don’t want to use SPAsyncLoading for the covers is to load the tracks using SPAsyncLoading then KVO on each track’s album.cover property. To force all the covers to start loading, you need to call the the -startLoading method of each cover. For example:

    NSArray *tracksToGetArtFor = …; // Get some tracks;
    [SPAsyncLoading waitUntilLoaded:tracks timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedTracks, NSArray *notLoadedTracks) {
    
        NSArray *coverArts = [tracks valueForKey:@"album.cover"]; // Get an array of the track's covers
    
        // Trigger the -startLoading method of each cover.
        [coverArts makeObjectsPerformSelector:@selector(startLoading)];
    
    ]};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.