Last active
January 14, 2021 15:59
-
-
Save thepearl/df4449f6815179e8cb07a6edd1b66b66 to your computer and use it in GitHub Desktop.
Movie cell definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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