Skip to content

Commit 1bc0d45

Browse files
committed
Merge pull request #10 from hyperoslo/improve/remote-image
Improve: public API
2 parents 892c571 + e296d26 commit 1bc0d45

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Example/ImaginaryDemo/ImaginaryDemo/ViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension ViewController {
6767
guard let cell = tableView.dequeueReusableCellWithIdentifier(
6868
FeedTableViewCell.reusableIdentifier) as? FeedTableViewCell else { return UITableViewCell() }
6969

70-
cell.generalImageView.setRemoteImage(imaginaryArray[indexPath.row])
70+
cell.generalImageView.setImage(imaginaryArray[indexPath.row])
7171

7272
return cell
7373
}

Example/ImaginaryDemo/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PODS:
44
- SwiftyJSON
55
- Imaginary (0.1.0):
66
- Cache
7-
- SwiftyJSON (2.3.1)
7+
- SwiftyJSON (2.3.2)
88

99
DEPENDENCIES:
1010
- Cache (from `https://github.com/hyperoslo/Cache`)
@@ -26,6 +26,6 @@ SPEC CHECKSUMS:
2626
Cache: 59ea9dbb71dfa1ba68a6efe295e907603b3066da
2727
Fakery: 593389814fb7c42fe7f0801e76c8ae55b95505e7
2828
Imaginary: feaea646440c68a9b6ed66a46597d548b9a44207
29-
SwiftyJSON: 592b53bee5ef3dd9b3bebc6b9cb7ee35426ae8c3
29+
SwiftyJSON: 04ccea08915aa0109039157c7974cf0298da292a
3030

3131
COCOAPODS: 0.39.0

Source/Extensions/UIImageView+Imaginary.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import UIKit
22

33
extension UIImageView {
44

5-
public func setRemoteImage(URL: NSURL, placeholder: UIImage? = nil) {
5+
public func setImage(URL: NSURL?, placeholder: UIImage? = nil) {
6+
image = placeholder
7+
8+
guard let URL = URL else { return }
9+
610
let key = URL.absoluteString
711

812
if let fetcher = fetcher {
913
fetcher.cancel()
1014
self.fetcher = nil
1115
}
1216

13-
image = placeholder
14-
1517
imageCache.object(key) { [weak self] object in
1618
guard let weakSelf = self else { return }
1719

0 commit comments

Comments
 (0)