title: How to update the row in my AddViewController with the new name
body: <p>I want to update the Row name in my itemViewController from the AddViewController. In my code I am passing the item object that contains the name and description to my AddViewController and changing the values however the rows name never gets updated.</p>
  <p>I looked around the internet and found information on what is called the delegate pattern to do this. I'm just not sure how to implement that pattern. Thank you for the help in advance.</p>
  <pre><code>//  ItemsViewController.swift
  //  Project 3-ToDo
  //
  //  Created by Gracias Claude on 10/9/20.
  //
  
  import UIKit
  
  class ItemsViewController : UITableViewController {
      var itemStore: ItemStore!
      
      
      
      @IBAction func addNewItem(_ sender: UIButton) {
          // Create a new item and add it to the store
          let newItem = itemStore.createItem()
  
          // Figure out where that item is in the array
          if let index = itemStore.allItems.firstIndex(of: newItem) {
              let indexPath = IndexPath(row: index, section: 0)
  
              // Insert this new row into the table
              tableView.insertRows(at: [indexPath], with: .automatic)
          }
         }
  
         @IBAction func toggleEditingMode(_ sender: UIButton) {
          // If you are currently in editing mode...
             if isEditing {
                 // Change text of button to inform user of state
                 sender.setTitle(&quot;Edit&quot;, for: .normal)
  
                 // Turn off editing mode
                 setEditing(false, animated: true)
             } else {
                 // Change text of button to inform user of state
                 sender.setTitle(&quot;Done&quot;, for: .normal)
  
                 // Enter editing mode
                 setEditing(true, animated: true)
             }
         }
      
      override func tableView(_ tableView: UITableView, 
              numberOfRowsInSection section: Int) -&gt; Int {
          return itemStore.allItems.count
      }
      
      // returning table view cell
      override func tableView(_ tableView: UITableView,
              cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          
  
              // Get a new or recycled cell
              let cell = tableView.dequeueReusableCell(withIdentifier: &quot;UITableViewCell&quot;,
                  for: indexPath)
  
          // Set the text on the cell with the description of the item
          // that is at the nth index of items, where n = row this cell
          // will appear in on the table view
          let item = itemStore.allItems[indexPath.row]
  
          cell.textLabel?.text = item.name
          cell.detailTextLabel?.text = &quot;\(item.dateCreated)&quot;
  
          return cell
      }
      
      override func tableView(_ tableView: UITableView,
                              commit editingStyle: UITableViewCell.EditingStyle,
                              forRowAt indexPath: IndexPath) {
          // If the table view is asking to commit a delete command...
          if editingStyle == .delete {
              let item = itemStore.allItems[indexPath.row]
  
              // Remove the item from the store
              itemStore.removeItem(item)
  
              // Also remove that row from the table view with an animation
              tableView.deleteRows(at: [indexPath], with: .automatic)
          }
      }
      override func tableView(_ tableView: UITableView,
                              moveRowAt sourceIndexPath: IndexPath,
                              to destinationIndexPath: IndexPath) {
          // Update the model
          itemStore.moveItem(from: sourceIndexPath.row, to: destinationIndexPath.row)
      }
      
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          // If the triggered segue is the &quot;showItem&quot; segue
          switch segue.identifier {
          case &quot;showItem&quot;:
              print(&quot;Hello World&quot;)
              // Figure out which row was just tapped
              if let row = tableView.indexPathForSelectedRow?.row {
  
                  // Get the item associated with this row and pass it along
                  let item = itemStore.allItems[row]
                  let detailViewController
                          = segue.destination as! DetailsViewController
                  detailViewController.item = item
              }
              break;
          
          case &quot;addItem&quot;:
              let row = tableView.indexPathForSelectedRow?.row ?? 0
  
  //                // Get the item associated with this row and pass it along
                  let item = itemStore.allItems[row]
                  let addViewController
                          = segue.destination as! AddViewController
                  addViewController.item = item
  //            }
              break;
          default:
              preconditionFailure(&quot;Unexpected segue identifier.&quot;)
          }
      }
  }
  
  //AddViewController
  
  //
  //  AddViewController.swift
  //  Project 3-ToDo
  //
  //  Created by Gracias Claude on 10/9/20.
  //
  
  import UIKit
  
  class AddViewController : UIViewController {
      
      
      var item: Item!;
     
    
      @IBOutlet weak var itemNameField: UITextField!
      @IBOutlet weak var priorityField: UITextField!
      @IBOutlet weak var descriptionField: UITextField!
      
      
      @IBAction func submitItem(_ sender: UIButton) {
          //how to update the existing Row name
          item.name = itemNameField.text ?? &quot;Default Text&quot;
          item.description = descriptionField.text ?? &quot;default Description&quot;
          
          return;
        
          
      }
  }
  </code></pre>