Reputation: 680
Considering I'm using PFImageViews, with caching enabled, I would like to know if there's a way to determine whether an image has already been downloaded or not.
All in all, I want to say:
if imageAlreadyDownloaded {
...
}
else {
...
}
Is it possible?
Upvotes: 1
Views: 159
Reputation: 680
So, I finally found the solution to my own problem! Every PFFile, has a boolean property called "isDataAvailable".
With a bit of code we can have the following solution:
let imageFile = file as? PFFile
if imageFile.isDataAvailable {
...
}
else {
...
}
And done! ;-)
Upvotes: 1
Reputation: 2593
I think you will have to roll your own solution using the PFImageView and the loadInBackground method that has a completion handler.
Something like:
// Instance property on your UIViewController
private var imageAlreadyDownloaded = false
// Somewhere else in your UIViewController...
imageView.loadInBackground() {
[unowned self] (image, error) in
guard error == nil else {
return
}
self.imageAlreadyDownloaded = true
}
Upvotes: 0