gpt4 book ai didi

ios - 使用 Swift 的 Firebase 用户收件箱

转载 作者:行者123 更新时间:2023-11-30 13:15:40 25 4
gpt4 key购买 nike

我正在尝试为我的应用程序中的用户创建一个收件箱。然而,我在重新加载 tableView 时遇到问题。如果我删除 self.tabelView.reloadData()应用程序 View 运行良好,但当然不会更新表格单元格。查询确实成功了,因为我可以打印结果数组。我收到的错误是 LLDB 错误。它指出“EXC_BreakPoint”,我没有设置任何断点。这是我的代码:

class InboxTableViewController: UITableViewController {

var pinggedUser: String!

var toBeUserId: String!


let dataBase = FIRDatabase.database()

var SecondResultArray: [FIRDataSnapshot]! = []



override func viewDidLoad() {



messageReference = rootReference.child("messages")

//let UserRef = messageReference.child((FIRAuth.auth()?.currentUser?.displayName)!)

messageReference.queryOrderedByChild("senderName")
.observeSingleEventOfType(.Value, withBlock:{ snapshot in
for child in snapshot.children {


self.SecondResultArray.append(child as! FIRDataSnapshot)
//print(self.ResultArray)


}

print(self.SecondResultArray )

self.tableView.reloadData()


})


super.viewDidLoad()

// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}



override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return SecondResultArray.count
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("inboxCell", forIndexPath: indexPath)

// Configure the cell...

let inBox: FIRDataSnapshot! = self.SecondResultArray[indexPath.row]

let book = inBox.value as! Dictionary<String, String>



let receiver = book["receiver"] as String!

let senderId = book["senderId"] as String!

let messageText = book["text"] as String!


let senderName = book["senderName"] as String!


cell.textLabel?.numberOfLines = 0
cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping



cell.textLabel?.text = "Your Messages With:" + "" + senderName


return cell
}


}

最佳答案

可能是您没有注册您的桌面 View 。

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")

关于ios - 使用 Swift 的 Firebase 用户收件箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38258254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com