How can i make a function using cocoalibspotify that checks if track is starred and display the star next to the starred track (TABLE)

StackOverflow https://stackoverflow.com/questions/18869727

  •  29-06-2022
  •  | 
  •  

質問

I want to add an option to my spotify application which using Cocoalibspotify (iOS) that will mark all the Starred song with some image that i'v made, the problem is that: for checking if SPTrack is starred or not i should load the track using SPASYNCLOADING method which returns void. so basically for each cell on the table i will take the spotify ID and load the track to know if the track is starred or not. I wanted to know if there is another way to do it ? since on those SPASYCNLOADING methods you can't return value.

役に立ちましたか?

解決

Well, if you're able to put the tracks into a table and have the track's title show up, the track is loaded enough to show whether it's starred or not, so you can just check the starred property of the track.

Otherwise, you could do:

UITableViewCell *cell = …;
SPTrack *track = …;

[SPAsyncLoading waitUntilLoaded:track timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedItems, NSArray *notLoadedItems) {

    if (notLoadedItems.count > 0) {
        // Track didn't load, so bail out.
        return;
    }

    if (track.starred) {
        cell.imageView.image = [UIImage imageNamed:@"starred"];
    } else {
        cell.imageView.image = nil;
    }
}];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top