Simple iOS framework to help download and cache files
If you are using CocoaPods add this text to your Podfile and run pod install
.
use_frameworks!
target 'Your target name'
pod 'Valley'
Add import Valley
to your code
From your UIImageView instance, you can just:
imageView.valleyImage(url: "https://yourwebseite.com/img.jpeg")
// Data to fill a webview with a PDF
ValleyFile.request(url: “https://yourwebsite.com/myfile.pdf“) { (data) in }
## Canceling download
To manually cancel the download, call:
```Swift
let task = imageView.valleyImage(url: "https://yourwebseite.com/img.jpeg")
task.cancel()
You can supply an error image that will be used if an error occurs during image download.
imageView.valleyImage(url: "https://yourwebseite.com/img.jpeg", placeholder: image)
The following method clear all items from cache
Valley.cache.clearCache()
Use Valley.setup(capacity: Int)
to define a capacity in bytes to cache.
The demo iOS app shows how to load images in a collection view with Valley and also load files like JSON.
Here is the list of other image download libraries for Swift.
Valley is released under the MIT License.
If you notice any issue, got stuck or just want to chat feel free to create an issue. I will be happy to help you.