I'm new in Swift and I'm trying to display inside a SwiftUI ListView :
- some datas
- an image (linked to datas)
It's kind of a contact app.
All these datas are stored in firestore. I created a function which gives the image URL on firestore :
func getURL(path: String, completion: @escaping (((URL?) -> Void))) {
let storage = Storage.storage()
storage.reference().child(path).downloadURL(completion: { url, error in
guard let url = url, error == nil else {
return
}
let urlPath = url.absoluteURL
completion(urlPath)
})
}
But when i call this function in the SwiftUI View, the following error appears :
"Type '()' cannot conform to 'View'; only struct/enum/class types can conform to protocols"
There is the calling code of the function :
getURL(path: bike.access1, completion: { path in AnimatedImage(url: path)})
I'm aware that i can't call function inside a view, but i don't see how to manage to display an image from Firestore inside a SwiftUI List View. If anyone know a strategy, I'm really interested. Thanks in advance Jean