I am able to fetch json from an api. I have populated all the other views except the imageView
. I have an array of images which are string urls. I want to download these images. I'm currently using SDWebImage
. I need to convert this array into a string one so i can fetch the images. I'm currently getting an error saying this since url is supposed to be string
Cannot convert value of type '[Images]?' to expected argument type 'String'
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
}
}