title: Pass textfield to a label in a second view controller in swift
body: <p>I am making a simple client invoice list using a tableView with custom labels in each row. at the top you click the plus sign. This takes you to a second page where you type in your clients name. you hit save and it should add it to the label in the first view controller. I cannot get this to work.</p>
  <p>my tableview storyboard has the file called <code>ViewController.swift</code> - in it</p>
  <pre><code>import UIKit
  
  var invoiceList = [&quot;&quot;]
  
  class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource   {
    
      @IBOutlet var clientTableView: UITableView!
      
      @IBOutlet var clientLabel: UILabel!
      
      public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
       return invoiceList.count
      }
      
  
      public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell
      {
          let cell = tableView.dequeueReusableCell(withIdentifier: &quot;clientItem&quot;, for: indexPath) as! UITableViewCell
          
          let ClientName = invoiceList[indexPath.row]
          cell.textLabel?.text = [clientInput]
          
          return cell
      }
      
      func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
          if editingStyle == UITableViewCellEditingStyle.delete
          {
              invoiceList.remove(at: indexPath.row)
              clientTableView.reloadData()
          }
      }
      
      override func viewDidAppear(_ animated: Bool) {
          clientTableView.reloadData()
      }
      
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          
      }
      
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  </code></pre>
  <p>My second storyboard where you type in the text field. File is called <code>AddInvoiceItem.swift</code>. in it -</p>
  <pre><code>import UIKit
  
  class AddInvoiceViewController: UIViewController  {
  
      var clientTextField:String!
      @IBOutlet var clientInput: UITextField!
      
      @IBAction func addItem(_ sender: Any) {
          
          if clientInput.text != &quot;&quot;
          {
          invoiceList.append(clientInput.text!)
          clientInput.text = &quot;&quot;
              
          _ = navigationController?.popViewController(animated: true)
          }
      }
      
      @IBAction func cancelBtn(_ sender: Any) {
          
          _ = navigationController?.popViewController(animated: true)
  
      }
      
  }
  </code></pre>
  <p>My error keeps happening when I am trying to use the code line</p>
  <pre><code>public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell
      {
          let cell = tableView.dequeueReusableCell(withIdentifier: &quot;clientItem&quot;, for: indexPath) as! UITableViewCell
          
          let ClientName = invoiceList[indexPath.row]
          cell.textLabel?.text = [clientInput]
          
          return cell
      }
  </code></pre>
  <p>The <code>cell.textLabel?.text = [clientInput]</code>
  I know this is wrong, but cannot figure it out!</p>
  <p><a href="https://i.stack.imgur.com/WElie.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WElie.png" alt="enter image description here" /></a></p>