Skip to content

Commit 0d88993

Browse files
author
pixel-ink
committed
READMEのアップデート
1 parent 7f65c9b commit 0d88993

2 files changed

Lines changed: 61 additions & 9 deletions

File tree

PIImageCache/PIImageCacheTests/PIImageCacheTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,24 @@ class PIImageCacheTests: XCTestCase {
254254
}
255255
}
256256

257+
func testREADME() {
258+
let url = NSURL(string: "http://place-hold.it/200x200")!
259+
var image = url.getImageWithCache()
260+
XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
261+
let imgView = UIImageView()
262+
imgView.imageOfURL(url) {
263+
isOK in
264+
XCTAssert(isOK , "Pass")
265+
}
266+
var cache = PIImageCache()
267+
image = cache.get(url)!
268+
XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
269+
var config = PIImageCache.Config()
270+
config.maxCount = 5
271+
config.maxByteSize = 100
272+
cache.setConfig(config)
273+
image = cache.get(url)!
274+
XCTAssert(image!.size.width == 200 && image!.size.height == 200 , "Pass")
275+
}
276+
257277
}

README.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,57 @@
77

88
## NSURL -> UIImage with cache (swift)
99

10-
![](https://cocoapod-badges.herokuapp.com/l/PIRipple/badge.png)
11-
![](https://cocoapod-badges.herokuapp.com/p/PIRipple/badge.png)
10+
![](https://cocoapod-badges.herokuapp.com/l/PIImageCache/badge.png)
11+
![](https://cocoapod-badges.herokuapp.com/v/PIImageCache/badge.png)
12+
![](https://cocoapod-badges.herokuapp.com/p/PIImageCache/badge.png)
1213

1314
---
1415

16+
1517
# install
1618

1719
- manually
1820
- add PIImageCache.swift into your project
21+
- cocoapods
22+
- add " pod 'PIImageCache', '0.1.1' " into your Podfile
23+
- add " import PIImageCache " into your code
24+
25+
# basic usage
1926

20-
# usage
27+
## NSURL extension
2128

22-
- create cache instance
23-
- get image by NSURL extension
29+
```NSURL.swift
30+
let url = NSURL(string: "http://place-hold.it/200x200")!
31+
let image = url.getImageWithCache()
32+
```
2433

25-
# example
34+
## UIImageView extension
2635

36+
```UIImageView.swift
37+
let url = NSURL(string: "http://place-hold.it/200x200")!
38+
let imgView = UIImageView()
39+
imgView.imageOfURL(url)
2740
```
28-
let url = NSURL(string: "http://place-hold.it/200x200")!
29-
let cache = PIImageCache()
30-
url.getImageWithCache(cache)
41+
42+
## for background
43+
44+
```PIImageCache.swift
45+
let url = NSURL(string: "http://place-hold.it/200x200")!
46+
let cache = PIImageCache.shared
47+
image = cache.get(url)!
3148
```
49+
50+
# advanced usage
51+
52+
## configurable
53+
54+
```Config.swift
55+
let cache = PIImageCache.shared
56+
var config = PIImageCache.Config()
57+
config.maxCount = 5
58+
config.maxByteSize = 100
59+
cache.setConfig(config)
60+
61+
let url = NSURL(string: "http://place-hold.it/200x200")!
62+
let image = cache.get(url)!
63+
```

0 commit comments

Comments
 (0)