我有这样的数据库参考,
我的Firebase Referance:
我想删除红色区域:
我用于通过电子邮件进行用户身份验证。 我的代码在这里:
import UIKit
import Firebase
class bakimKayitlarimVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
var todoList = [BakimlarListe]()
private var databaseHandle: FIRDatabaseHandle!
var databaseRef: FIRDatabaseReference! {
return FIRDatabase.database().reference()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
tableView.allowsMultipleSelectionDuringEditing = true
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
//I want to this code?? Please Help Me..
}
}
func loadData() {
self.todoList.removeAll()
let userReference = databaseRef.child("users/\(FIRAuth.auth()!.currentUser!.uid)")
userReference.child("bakimlar").observeSingleEvent(of: .value, with: { (snapshot) in
if let todoDict = snapshot.value as? [String:AnyObject] {
for (_,todoElement) in todoDict {
print(todoElement);
let todo = BakimlarListe()
todo.bakimKm = todoElement["bakimkm"] as? String
todo.sonrakiBakimKm = todoElement["sonrakibakimkm"] as? String
todo.tarih = todoElement["tarih"] as? String
todo.degisenler1 = todoElement["degisenler1"] as? String
todo.degisenler2 = todoElement["degisenler2"] as? String
todo.degisenler3 = todoElement["degisenler3"] as? String
todo.degisenler4 = todoElement["degisenler4"] as? String
todo.degisenler5 = todoElement["degisenler5"] as? String
todo.degisenler6 = todoElement["degisenler6"] as? String
todo.degisenler7 = todoElement["degisenler7"] as? String
todo.degisenler8 = todoElement["degisenler8"] as? String
todo.degisenler9 = todoElement["degisenler9"] as? String
todo.degisenler10 = todoElement["degisenler10"] as? String
todo.degisenler11 = todoElement["degisenler11"] as? String
todo.degisenler12 = todoElement["degisenler12"] as? String
todo.degisenlerDetay = todoElement["degisenlerDetay"] as? String
self.todoList.append(todo)
}
}
self.tableView.reloadData()
}) { (error) in
print(error.localizedDescription)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.todoList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyCustomCell
// populate the data in your cell as desired
cell.bakimKmLabel.text = todoList[indexPath.row].bakimKm
cell.sonrakiBakimKmLabel.text = todoList[indexPath.row].sonrakiBakimKm
cell.tarihLabel.text = todoList[indexPath.row].tarih
cell.degisenler1Label.text = todoList[indexPath.row].degisenler1
cell.degisenler2Label.text = todoList[indexPath.row].degisenler2
cell.degisenler3Label.text = todoList[indexPath.row].degisenler3
cell.degisenler4Label.text = todoList[indexPath.row].degisenler4
cell.degisenler5Label.text = todoList[indexPath.row].degisenler5
cell.degisenler6Label.text = todoList[indexPath.row].degisenler6
cell.degisenler7Label.text = todoList[indexPath.row].degisenler7
cell.degisenler8Label.text = todoList[indexPath.row].degisenler8
cell.degisenler9Label.text = todoList[indexPath.row].degisenler9
cell.degisenler10Label.text = todoList[indexPath.row].degisenler10
cell.degisenler11Label.text = todoList[indexPath.row].degisenler11
cell.degisenler12Label.text = todoList[indexPath.row].degisenler12
cell.degisenlerDetayLabel.text = todoList[indexPath.row].degisenlerDetay
return cell
}
}
class MyCustomCell: UITableViewCell {
@IBOutlet weak var bakimKmLabel: UILabel!
@IBOutlet weak var sonrakiBakimKmLabel: UILabel!
@IBOutlet weak var tarihLabel: UILabel!
@IBOutlet weak var degisenler1Label: UILabel!
@IBOutlet weak var degisenler2Label: UILabel!
@IBOutlet weak var degisenler3Label: UILabel!
@IBOutlet weak var degisenler4Label: UILabel!
@IBOutlet weak var degisenler5Label: UILabel!
@IBOutlet weak var degisenler6Label: UILabel!
@IBOutlet weak var degisenler7Label: UILabel!
@IBOutlet weak var degisenler8Label: UILabel!
@IBOutlet weak var degisenlerDetayLabel: UILabel!
@IBOutlet weak var degisenler9Label: UILabel!
@IBOutlet weak var degisenler10Label: UILabel!
@IBOutlet weak var degisenler11Label: UILabel!
@IBOutlet weak var degisenler12Label: UILabel!
}
感谢您的帮助。