문제

I am trying to get artworks or album covers using spotify API. I am using:

NSString *url = @"http://ws.spotify.com/search/1/track.json";

NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                               ([Utils isEmptyString:_searchBar.text] ? @"music" : _searchBar.text), @"q", nil];

[self sendRequestWith:url params:params method:RequestMethodGET success:^(AFHTTPRequestOperation *operation, id response, NSDictionary *userData) {
    NSDictionary *result = (NSDictionary *)response;
    if(result){
        [_trackList removeAllObjects];
        NSArray *tracks = [Utils getDictionaryValue:result by:@[@"tracks"]];
        for (NSDictionary *trackData in tracks) {
            WPTrack *track = [[WPTrack alloc] initWithSpotifyJSON:trackData];
            [_trackList addObject:track];
        }
        [listViewController updateWithObjects:_trackList];
    }
} failure:^(AFHTTPRequestOperation *operation, NSError *error, NSDictionary *userData) {

} userData:nil];

The current method I am getting doesn't seem to return the thumbnail of the track. But it returns "href" of the track which I can use to search for the track's image by https://embed.spotify.com/oembed/?url=spotify:track:6bc5scNUVa3h76T9nvpGIH. However, this might be another request which could slow my loading on the UITableView. Is there a better way to do this process together?

도움이 되었습니까?

해결책

It common practice to not include rich media content in a api response as the client will have to wait until everything has been sent which can take a long time. To speed up the process you should parser the information gathered and display that to the user while you have another asynchronously operation using a Block to retrieve the image and display it.

Using Async call with cell example

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top