参数标签'(contentsOfURL:,options:,error :)'不匹配任何可用的重载

时间:2016-01-20 18:33:43

标签: swift uiimageview nsdata spotify

在youtube上关注spotify swift tuturiol,但目前在以下行中收到以下错误Argument labels '(contentsOfURL:, options:, error:)' do not match any available overloads

if let imageData = NSData(contentsOfURL: imgURL, options: nil, error: &error) {

上下文

func updateCoverArt() {
    if player?.currentTrackMetadata == nil {
        artworkImageView.image = UIImage()
        return
    }

    let uri = player?.currentTrackMetadata[SPTAudioStreamingMetadataTrackURI] as! String

    SPTAlbum.albumWithURI(NSURL(string: uri), session: session) { (error:NSError!, albumObj:AnyObject!) -> Void in
        let album = albumObj as! SPTAlbum

        if let imgURL = album.largestCover.imageURL as NSURL! {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
                var error:NSError? = nil
                var coverImage = UIImage()

                if let imageData = NSData(contentsOfURL: imgURL, options: nil, error: &error) {
                    if error == nil {
                        coverImage = UIImage(data: imageData)!
                    }
                }

                dispatch_async(dispatch_get_main_queue(), { () -> Void in
                    self.artworkImageView.image = coverImage
                })

            })
        }
    }
}

0 个答案:

没有答案