Reputation: 854
I have a project in which i have a image view (in Xcode 7.3). I need to show an image from my firebase storage and to my UIImageView, right now i am using this code: (but it's really slow - each time i enter the view it takes 3-4 seconds to show my image)
func showImage(){
FIRStorage.storage().referenceForURL("https://firebasestorage.googleapis.com/v0/b/restaurantproject-27368.appspot.com/o/bestdeal.jpg?alt=media&token=dcbd9da1-d368-48ef-8ed2-a861103e4ab8").dataWithMaxSize(10 * 1024 * 1024, completion: { (data, error) in
dispatch_async(dispatch_get_main_queue()) {
self.myImageView.image = UIImage(data: data!)
}
})
}
Is there maybe a better way? (plus i need to cache it somehow in my device but i need it to check my image every time i enter the app because i need to change an image in my firebase storage sometimes and i want the app to keep showing the updated image,
Thank you!!
Upvotes: 0
Views: 361
Reputation: 564
Kingfisher library can be used to cache the image. It checks for change in the image too. After installing kingfisher lib.you can do the following:
imageView.kf_setImageWithUrl(imageUrl)
Upvotes: 2