How can I get deleted textfield values?

I have tableview cell with textfield in it. User can enter a values and add new row of the table. In this point, when tableview become long and some textfields disappeared from screen, this textfield's values deleted. I already tried prepareforreuse but it wasn't work. Textfield delegate methods working but I can't get deleted values again. How can I get these values?


extension taslakOlusturmaController: UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  return taskArrForRead.count
  }

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  let cell = tableView.dequeueReusableCell(withIdentifier: "taslakCell", for: indexPath) as! taslakDuzenlemeCell

  cell.taslakTextField.text = taskArrForRead[indexPath.item]
  cell.taslakTextField.delegate = self
  return cell
  }

  func textFieldDidEndEditing(_ textField: UITextField) {
  print(textField.text!)
  self.arrayOfNames.append(textField.text!)
  }

  func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
  let cell = tableView.dequeueReusableCell(withIdentifier: "taslakCell", for: indexPath) as! taslakDuzenlemeCell
  cell.taslakTextField.text = taskArrForRead[indexPath.item]
  print(arrayOfNames[indexPath.item])
  }
}


Here my tableview delegate functions. This taskArrForRead array hold my datas. Last two methods writing for get all elements in textfields for writing to database. Please help me. I have to solve.

I dont understand your point.


Data in tableView are not (or should not be) stored in tableView but in its datasource, which is a permanent storage.

In your case, seems it is taskArrForRead.


Why should data be deleted from this array unless you explicitely ask for it ?


I don't understand why you need to define a delegate for the cell, but maybe I miss some point in your non posted code.

@mnaultra

Any further explanation by answering the above questions ?

If no more need for answers, please close the thread.

How can I get deleted textfield values?
 
 
Q