Skip to content

Instantly share code, notes, and snippets.

@thepearl
Last active January 14, 2021 15:59
Show Gist options
  • Save thepearl/df4449f6815179e8cb07a6edd1b66b66 to your computer and use it in GitHub Desktop.
Save thepearl/df4449f6815179e8cb07a6edd1b66b66 to your computer and use it in GitHub Desktop.
Movie cell definition
import UIKit
import SDWebImage
class MovieCell: UITableViewCell
{
@IBOutlet weak var movieImageView: UIImageView!
@IBOutlet weak var movieNameLabel: UILabel!
@IBOutlet weak var movieDetailsLabel: UILabel!
var movieObject: Result!
{
didSet
{
setupData()
}
}
func setupData()
{
guard
let unwrappedMovieName = movieObject.title,
let unwrappedMovieDetails = movieObject.resultDescription
else { return }
movieNameLabel.text = unwrappedMovieName
movieDetailsLabel.text = unwrappedMovieDetails
if
let unwrappedMovieImage = movieObject.image,
let imageURL = URL(string: unwrappedMovieImage)
{
movieImageView.activateSdWebImageLoader()
movieImageView.sd_setImage(with: imageURL, completed: nil)
}
else
{
movieImageView.image = UIImage(named: "placeholder-image")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment