简体   繁体   中英

Get SPTImage from NSURL?

我使用Spotify的新的iOS SDK测试版,不知道是否有一种方法来检索SPTImage从NSURL(最初是从提取SPTPartialAlbum.covers属性,或者只有这样,才能找回它是从获得SPTPartialAlbum第一?

I was able to accomplish this with the following code:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSError *error;
    NSData *imageData = [NSData dataWithContentsOfURL:URL options:0 error:&error];
    if (imageData) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (completion) completion([UIImage imageWithData:imageData]);
        });
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM