I am working in swift. I have a textfield that is in a tableview cell. I am trying to store the text of each text field in the tableview so they when the user adds or deletes a row, and then the tableview reloads data, that the text fields stay filled in with the appropriate data.
I tried adding a textfielddidendeditting function but for some reason it is not being called.
EDIT:
Here is my code:
tableViewController:
import UIKit
var rowCount = 0
var textArray = [String]()
class TableViewController: UITableViewController {
override func viewDidLoad() {
    super.viewDidLoad()
}
override func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return rowCount
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
    return cell
}
@IBAction func addRow(_ sender: Any) {
    rowCount = rowCount + 1
    textArray.append("")
    tableView.reloadData()
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        rowCount = rowCount - 1
        textArray.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .fade)
    } else if editingStyle == .insert {
    }
}
}
tableViewCell:
import UIKit
class TableViewCell: UITableViewCell, UITextFieldDelegate {
@IBOutlet weak var textField: UITextField!
override func awakeFromNib() {
    super.awakeFromNib()
    textField.delegate = self
}
override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
    // Configure the view for the selected state
}
func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
    if let myIndexPath = tableView.indexPathForSelectedRow {
        let newText = textField.text
        textArray.insert(newText, at: myIndexPath)
    }
    return true
}
}