Fetching data from firestore for a label in a viewcontroller

Hi There!
I am trying to run a function that checks to see how many documents are in a collection, if there is only one, I want to populate a label in a view controller with the result. The purpose is to make it easy for the user if there is only one document. If there are several documents, I have a picker view pop up and allow the user to make a selection. My problem is if I run the function prior to viewdidload, the label cannot get the new value in time (I think), so I tried dispatchqueue.main.async and that did not help. I want this function to run in the background once the user selects the viewcontroller?
Here is my function

static func checkQuantityOfHorses() {
let db = Firestore.firestore()
let docCount = db.collection(“Profile”)
docCount.whereField:userName", isEqualTo: Auth.auth()currentUser?.email! as Any).getDocuments() {
(querySnapshot, err) in
if let err = err {
print(“Error getting documents”)
} else {
var count = 0
for document in querySnapshot!.documents {
count += 1
print(document.documentID) // documentID is a named ID which I use
if count >=2 {
GlobalV.actualHorse = “Select a horse”
} else {GlobalV.actualHorse = document.documentID
then after - override func viewDidLoad() {
super viewDidLoad
DispatchQueue.main.async {
self.yourMustangName.text = GlobalV.actualHorse
My result provides the default value for GlobalV.actualHorse not the documentID value.

Any help or guidance would be appreciated!