I'm new to Swift and I am trying to return the values of the variables created in this function. I have been facing this issue for quite some time now and was hoping anyone can shed some light on this and help me out. I have tried changing the return type of the function and that did not work. Any help would be greatly appreciated
Here's the code:
func grabData1() -> (String, String, String) {
db.collection("News").document("Article 1").getDocument { (document, error) in
if error == nil {
if document != nil && document!.exists{
self.headline1 = document?.get("Headline").map(String.init(describing:)) ?? nil
var article = document?.get("Article").map(String.init(describing:)) ?? nil
var image1URL = URL(string: document?.get("Image") as! String)
return (headline1, article, image1URL)
}
}
}
}