Created
March 29, 2021 09:25
-
-
Save KrauserHuang/3dd402ad8cb55db00a5bdcb3b15df1a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loadUser() { | |
db.collection(Constant.FireStore.users).getDocuments { (querySnapshot, error) in | |
if let error = error { | |
print("There was an issue retrieving data to Firestore. \(error)") | |
} else { | |
if let snapshotDocuments = querySnapshot?.documents { | |
for doc in snapshotDocuments { | |
let data = doc.data() | |
if let userName = data[Constant.FireStore.userName] as? String { | |
// label顯示速度有差,再確認 | |
DispatchQueue.main.async { | |
self.welcomeLabel.text = "Welcome, \(userName)" | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment