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 ...
感谢的人!说得通 –