Manos Chorianopoulos

fix image caching at coupon cell

......@@ -16,6 +16,24 @@ import UIKit
@IBOutlet weak var dicountLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.couponImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.couponImage.image = image
}
}
}
else {
self.couponImage.image = nil
}
}
}
public override func awakeFromNib() {
......@@ -54,7 +72,8 @@ import UIKit
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
nameLabel.text = merchant._admin_name
break;
}
......