title: Text field delegate in table view error: index is out of range swift
body: <p>I am trying to get every input that typed in the text field. I used this in my other view it works, but here I have different case within 1 section (should be easier) but I don't why, the index is out of range. Here's the code:</p>
  <pre><code>import UIKit
  
  struct SpecData {
  var server: Int
  var core: Int
  var userCAL: Int
  var deviceCAL: Int
  }
  
  var arraySpecDataInputed = [SpecData]()
  
  extension SpecVC: UITableViewDelegate, UITableViewDataSource {
  func numberOfSections(in tableView: UITableView) -&gt; Int {
      return 4
  }
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      switch section {
      case 1:
          return 4
      default:
          return 1
      }
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  let inputCell = tableView.dequeueReusableCell(withIdentifier: LicenseInputTVCell.cellIdentifier, for: indexPath) as! LicenseInputTVCell
  
  switch indexPath.section {
  case 1:
          inputCell.labelSpec.text = specServer[indexPath.row].spec
          inputCell.textfieldInput.delegate = self
          inputCell.textfieldInput.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
          inputCell.textfieldInput.tag = indexPath.row
          
          return inputCell
  default:
          return inputCell
       }
     }
  }
  
  extension SpecVC: UITextFieldDelegate {
       @objc func textFieldDidChange(_ sender: UITextField) {
           let rowIndex = sender.tag
           let indexPath = IndexPath(row: rowIndex, section: 1)
           let cell = tableView.cellForRow(at: indexPath) as! LicenseInputTVCell
           if rowIndex == 0 {
               arraySpecDataInputed[rowIndex].server = Int(cell.textfieldInput.text!) ?? 0 // Fatal Error: Index out of range
           }
       }
  }
  </code></pre>
  <p>When I tried to start typing 1 digit of number in the textField, the app was error with index out of range. I tried to input some different numbers in the <code>[rowIndex]</code> but it doesn't work.
  Can anyone tell me what did I do wrong here? What should be filled in the <code>[rowIndex]</code>?</p>
  <p>Thank you in advance</p>