I am trying to make my function to read data from Firebase Storage taking image reference as an input and getting UIImage in return.
It gives me error: Cannot convert return expression of type 'StorageDownloadTask' to return type 'UIImage'
As I see, the problem is that Firebase function already has a return and it conflicts with my function. As a solution, I have tried to make the function return several values but with no success.
Is there any way to solve this issue? I would really appreciate any help.
func convertImage(imageRef: String) -> UIImage {
storage.reference().child("images").child(imageRef).getData(maxSize: 2 * 2048 * 2048) { data, error in
var image = UIImage(named: "empty_plate")
if let error = error {
print(error)
} else {
image = UIImage(data: data!)
}
return image
}
}