Advertisement
Guest User

Untitled

a guest
Oct 27th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  2. return 60
  3. }
  4.  
  5. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  6. let cell = tableView.dequeueReusableCell(withIdentifier: catsTableViewCellIdentifier, for: indexPath) as! CatsTableViewCell
  7.  
  8. catRequest.getCat(completionSuccess: { (image) in
  9. DispatchQueue.main.async {
  10. cell.catImageView.image = image
  11. }
  12. }) { (error) in
  13.  
  14. }
  15.  
  16. return cell
  17. }
  18.  
  19.  
  20. class CatsTableViewCell: UITableViewCell {
  21.  
  22. @IBOutlet weak var catImageView: UIImageView!
  23.  
  24. var catRequest = CatRequest()
  25.  
  26. override func awakeFromNib() {
  27. super.awakeFromNib()
  28. catImageView.layer.cornerRadius = 5
  29. }
  30.  
  31. override func setSelected(_ selected: Bool, animated: Bool) {
  32. super.setSelected(selected, animated: animated)
  33. }
  34.  
  35. override func prepareForReuse() {
  36. super.prepareForReuse()
  37. catImageView.image = nil
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement