Commit 4e852578 authored by Zandor Smith's avatar Zandor Smith 💻

Add init function to cache an image that is already available in memory locally.

parent 3ee15c74
......@@ -21,10 +21,18 @@ open class Image {
return PINCache.shared().containsObject(forKey: self.url)
}
/// Create Image object from url.
public init(url: String) {
self.url = url
}
/// Create Image object with url and data.
/// Example: After uploading the image, automatically cache the uploaded data to prevent having to download the iamge again.
public init(url: String, imageData: NSData) {
self.url = url
PINCache.shared().setObject(imageData, forKey: url)
}
public func removeCachedImage() {
PINCache.shared().removeObject(forKey: self.url)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment