Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return 60
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: catsTableViewCellIdentifier, for: indexPath) as! CatsTableViewCell
- catRequest.getCat(completionSuccess: { (image) in
- DispatchQueue.main.async {
- cell.catImageView.image = image
- }
- }) { (error) in
- }
- return cell
- }
- class CatsTableViewCell: UITableViewCell {
- @IBOutlet weak var catImageView: UIImageView!
- var catRequest = CatRequest()
- override func awakeFromNib() {
- super.awakeFromNib()
- catImageView.layer.cornerRadius = 5
- }
- override func setSelected(_ selected: Bool, animated: Bool) {
- super.setSelected(selected, animated: animated)
- }
- override func prepareForReuse() {
- super.prepareForReuse()
- catImageView.image = nil
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement