I am having an issue updating my UITableView. I have an app that has a basic UIViewController with a with a navigationItem to "Add New" items to the UITableViewContioller. I can add the string and then dump the array to see if it has been added. The dump function shows the added item in the array but the UITableView does not, even after calling reloadData. Here is my code.
Here is the console dump after hitting save.
So you can see something is there after I save but nothing shows up on the UITableview.
From the UIViewController class I have a UIAlertAction to accept text and a save button.
let table = TableViewController()
let saveAction = UIAlertAction(title: "Save", style:UIAlertActionStyle.Default, handler: {
alert -> Void in
let firstTextField = alertController.textFields![0] as UITextField
self.table.cityArry.addObject(firstTextField.text!)
self.table.refresh()
})
And from UITableViewController class
class TableViewController: UITableViewController {
var cityArry:NSMutableArray = ["Local"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}
func refresh(){
dump(cityArry)
tableView.reloadData()
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cityArry.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let item = cityArry[indexPath.row]
let cell = UITableViewCell()
let label = UILabel(frame: CGRect(x:20, y:0, width:200, height:50))
label.text = item as? String
cell.addSubview(label)
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Nothing here yet
}
}


tabledisplaying on your screen is the one you callrefreshon?