Reputation: 209
I am appending data from parse into an array, but when I try to load array in table view nothing shows up. The array is populated, but nothing is showing up. How do I fix this?
class View2: UIViewController, UITableViewDataSource, UITableViewDelegate{
var ret = [String]()
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ret.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = table.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
cell.textLabel?.text = ret[indexPath.row]
return cell
}
}
Upvotes: 0
Views: 900
Reputation: 1661
in my case I forgot to connect the UITableView datasource outlet to the ViewController.
Upvotes: 1
Reputation: 225
After set 'ret' value, you have to reload table.
In my case,
var ret = [String](){
didSet{
self.tableView.reloadData()
}
}
Upvotes: 2
Reputation: 1680
Add a call to reloadData()
method of UITableView
in the setter of your array.
Upvotes: 0
Reputation: 2246
Ensure your tableview is being reloaded after you receive the data. Use tableViewName.reloadData()
Upvotes: 0