我能够从 api 获取 json。我已经填充了除imageView
. 我有一组图像,它们是字符串 url。我想下载这些图片。我目前正在使用SDWebImage
. 我需要将此数组转换为字符串,以便获取图像。我目前收到一条错误消息,因为 url 应该是字符串
无法转换类型“[图像]?”的值 到预期的参数类型“字符串”
import SDWebImage
class AlbumCell: UITableViewCell {
@IBOutlet weak var albumImageView: UIImageView!
var album: Album? {
didSet {
guard let url = URL(string: album?.image) else { return }
albumImageView.sd_setImage(with: url, completed: nil)
}
}
}
struct Album: Decodable {
let name: String
let image: [Images]
let artist: String
}
struct Images: Decodable {
let text: String
let size: String
enum CodingKeys: String, CodingKey {
case text = "#text"
case size
}
}