首页 > 解决方案 > 如何获取所选行的textLabel并快速保存到firebase?

问题描述

我正在尝试获取我选择并保存到 Firebase 的行的 textLabel 的值。当我一次选择多行时,我想存储到 Firebase 数据库。这是我的代码。

ps 我是 Swift 新手。

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return guestList.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "guestListCell", for: indexPath) as! GuestListToTableTableViewCell
        let guest: GuestModel
        guest = guestList[indexPath.row]
        cell.fullNameLabel.text = guest.guestName! + " " + guest.guestFamilyName!
        cell.checkedImageView.image = UIImage(named: "unChecked")
        return cell
        
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableTableView.deselectRow(at: indexPath, animated: true)
        indexArray.append(indexPath.row)
     
        guard let cell = tableView.cellForRow(at: indexPath) as? GuestListToTableTableViewCell else { return }
            let name: GuestModel
            name =  guestList[indexPath.row]
            print("\(String(describing: name.guestName))") }

这是我的客人模特

class GuestModel {
    
    var guestName: String?
init(guestName: String?)
self.guestName = guestName } 

标签: iosswiftfirebaseuitableviewselect

解决方案


推荐阅读