I have object named myArray in firebase database structure and it has a multiple lines of strings as [a , b and c ] like this
how can I display this object in my Table View ,When I run it its coming in My Debug like this
but its not appears in my simulator its appease like this
,I am using swift 3
This is My Code :
import UIKit
import Firebase
class TestTable: UITableViewController {
var arrayList = [test]()
var Ref = FIRDatabaseReference()
override func viewDidLoad() {
super.viewDidLoad()
Ref=FIRDatabase.database().reference()
Ref.child("Users").child("Test").observe(.childAdded ,with: { (snapshot) in
if let User = snapshot.value as? [String : AnyObject]{
let Add = test()
Add.setValuesForKeys(User)
self.arrayList.append(Add)
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\(snapshot.value)")
self.tableView.reloadData()
}
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return arrayList.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return arrayList[section].myArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as!TestTableCell
let hh = indexPath.section
cell.myTestView.text = (arrayList[hh].myArray as AnyObject) as? String
cell.titleText.text = arrayList[hh].title
return cell
}
}
and this is My Class :
class test : NSObject {
var myArray : NSArray = []
var title : String?
}