My first View Controller has a TableView.
On a second view controller, the user will input data and click a button.
I want this button to add the data to the table view, but I can not figure out how to do this.
var textArray: NSMutableArray! = NSMutableArray()
@IBOutlet weak var tableView: UITableView!
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.textArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
@IBOutlet weak var addData: UIButton!
@IBAction func addData(sender: AnyObject) {
self.textArray.addObject(textField.text)
self.tableView.reloadData()
}
It also brings up an error for my reloadData
line of code.