I upload the data to the database successfully but I can't see the data in the cell of the list of the table view. I can't see even one cell. Please see my code of the table view controller :
var tutsArray = [Tutorials]()
var userArray = [Users]()
var dataBaseRef: DatabaseReference! {
return Database.database().reference()
}
override func viewDidLoad() {
super.viewDidLoad()
let ref = Database.database().reference()
ref.observe(.value, with: { snapshot in
/
var newItems: [Tutorials] = []
/
for item in snapshot.children {
/
let tut = Tutorials(snapshot: item as! DataSnapshot)
newItems.append(tut)
}
/
self.tableView.reloadData()
})
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let ref = Database.database().reference()
ref.queryOrdered(byChild: "tuts").observe(.value, with: { snapshot in
/
var newItems: [Tutorials] = []
/
for item in snapshot.children {
/
let tut = Tutorials(snapshot: item as! DataSnapshot)
newItems.append(tut)
}
/
self.tableView.reloadData()
})
loadData()
}
func loadData() {
self.tutsArray.removeAll()
let ref = Database.database().reference()
ref.child("tut").observeSingleEvent(of: .value, with: { (snapshot) in
if let todoDict = snapshot.value as? [String:AnyObject] {
}
self.tableView.reloadData()
}) { (error) in
print(error.localizedDescription)
}
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
/
return self.tutsArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "sharesCell", for: indexPath) as! ArtTutsTableViewCell
/
/
cell.tutName?.text = tutsArray[indexPath.row].tutName
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
_ = self.tutsArray[indexPath.row]
let tutorialViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "idTutorialViewController") as! ArtTutsViewController
/
showDetailViewController(tutorialViewController, sender: self)
}