Manos Chorianopoulos

fix image caching at coupon cell

...@@ -16,6 +16,24 @@ import UIKit ...@@ -16,6 +16,24 @@ import UIKit
16 @IBOutlet weak var dicountLabel: UILabel! 16 @IBOutlet weak var dicountLabel: UILabel!
17 @IBOutlet weak var discriptionLabel: UILabel! 17 @IBOutlet weak var discriptionLabel: UILabel!
18 @IBOutlet weak var expirationLabel: UILabel! 18 @IBOutlet weak var expirationLabel: UILabel!
19 +
20 + var postImageURL: String? {
21 + didSet {
22 + if let url = postImageURL {
23 + self.couponImage.image = UIImage() // UIImage(named: "loading")
24 +
25 + UIImage.loadImageUsingCacheWithUrlString(url) { image in
26 + // set the image only when we are still displaying the content for the image we finished downloading
27 + if url == self.postImageURL {
28 + self.couponImage.image = image
29 + }
30 + }
31 + }
32 + else {
33 + self.couponImage.image = nil
34 + }
35 + }
36 + }
19 37
20 38
21 public override func awakeFromNib() { 39 public override func awakeFromNib() {
...@@ -54,7 +72,8 @@ import UIKit ...@@ -54,7 +72,8 @@ import UIKit
54 72
55 for merchant in merchantList { 73 for merchant in merchantList {
56 if (merchant._uuid == couponSetData?.merchant_uuid) { 74 if (merchant._uuid == couponSetData?.merchant_uuid) {
57 - couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) 75 + // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
76 + self.postImageURL = merchant._img_preview
58 nameLabel.text = merchant._admin_name 77 nameLabel.text = merchant._admin_name
59 break; 78 break;
60 } 79 }
......