1
之前用戶沒有加載速度不夠快,我打這個按鈕火力地堡登錄賽格瑞
override func viewDidLoad() {
FIRAuth.auth()?.signIn(withEmail: "[email protected]", password: "password") {
(user, error) in
// TODO: SET UP A SPINNER ICON
print("Logged into hmk")
self.performSegue(withIdentifier: "login", sender: self)
}
}
正如你所看到的,在回調重定向到一個UITableViewController。該填充代碼位於UITableViewController的初始化程序中,封閉的唯一目的是填充self.chatsList
有時,每當我測試應用程序時,UITableViewController都是空白的。
ref.child("users").child(currentUser.uid).observeSingleEvent(of: .value, with: { (snapshot) in
guard snapshot.exists() else {
print("Error: Path not found")
return
}
let value = snapshot.value as? NSDictionary
// Convert a dict of dicts into an array of dicts
// You will lose chatID in the process, so be warned
// Unless you would like to to keep the data in a struct
for (chatIdKey, secondDict) in value?["chats"] as! [String: NSDictionary] {
// This only appends metadata for the last chat
// Does not load every chat message
self.chatsList.append(Chat(chatId: chatIdKey, targetChat: secondDict))
}
})
但是,當我打的返回鍵,等待足夠長的時間,並重新登錄,該表正確填充。
我怎樣才能確保它正確地加載每一次?我預計回調performSegue將保證我們有一個currentUser ...
感謝的人!說得通 –