So, I was trying to make Birthday App which notes name and birthday of the written textField values. When i press button, those values are saved in two separated Arrays. Those names will be seen on the tableView. I can't see nameArray values on cells but the program builds successfully.
My question is how can update tableView cell names with the values of my nameArray?
Thanks in advance
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
@IBOutlet weak var nameTF: UITextField!
@IBOutlet weak var birthdayTF: UITextField!
@IBOutlet weak var firstTV: UITableView!
var nameArray = [String]()
var birthdayArray = [String]()
let rowName = UITableViewCell()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
firstTV.delegate = self
firstTV.dataSource = self
}
@IBAction func saveButton(_ sender: Any) {
nameArray.append(nameTF.text!)
birthdayArray.append(birthdayTF.text!)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return nameArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
rowName.textLabel?.text = nameArray[indexPath.row]
return rowName
}
}