title: tableview to tableview protocol delegates
body: <p>I am trying to finish this app that is a form. once filled out a button later will be pushed for print. The first controller has a tableview that has page 1 page 2 page 3. page 1 opens and you fill in all info. when hit save it should take you back to first controller. then when you push print opens the tableview and loads all info.
  I am struggling to use structs correctly. also struggling on the save button to the delegate to the print controller page.</p>
  
  <p><a href="https://i.stack.imgur.com/4ymVD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ymVD.png" alt="enter image description here"></a></p>
  
  <p>my page controller code</p>
  
  <pre><code>class PagesController: UIViewController, UITableViewDelegate {
  
      var pages = ["Page 1","Page 2","Page 3"]
  
      @IBOutlet weak var pagesTableView: UITableView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          pagesTableView.delegate = self
          pagesTableView.dataSource = self
  
      }
  
      @IBAction func printBtnPressed(_ sender: Any) {
  
      } }
  
  extension PagesController: UITableViewDataSource {
      func numberOfSections(in tableView: UITableView) -&gt; Int {
          return 1
      }
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return pages.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "PagesCell")
  
          cell?.textLabel?.text = pages[indexPath.row]
  
          return cell!
      }
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          if indexPath.row == 0 {
              performSegue(withIdentifier: "ChildInfoSegue", sender: self)
          }
      }
  
      func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
          return 90.0
      }
       }
  </code></pre>
  
  <p>Heres my form controller</p>
  
  <pre><code>protocol ChildDelegate {
      func saveInfoBlock(form: ChildInfo)
  }
  
  class ChildInfoTableViewController: UITableViewController {
  
      var formDelegate: ChildDelegate!
  
      var firstNameText: UITextField = UITextField()
      var lastNameText: UITextField = UITextField()
      var middleNameText: UITextField = UITextField()
  
      //MARK: From ChildInfo.swift STRUCT
      var childInfo = [ChildInfo]()
  
      var basicChildInfo = ["Child's First Name","Child's Middle Name","Child's Last Name"]
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
  
      }
  
      override func numberOfSections(in tableView: UITableView) -&gt; Int {
          // #warning Incomplete implementation, return the number of sections
          return 1
      }
  
      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          // #warning Incomplete implementation, return the number of rows
          return basicChildInfo.count
      }
  
      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "ChildInfoCell") as! ChildInfoTableViewCell
  
          cell.formLabel.text = basicChildInfo[indexPath.row]
  
          return cell
      }
  
  
      //MARK: Segue to printController
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  
          let path = self.tableView.indexPathForSelectedRow!
  
          let destViewController = segue.destination as! PrintPageTableViewController
  
      }
  
      //MARK: Cancel Button Pressed
      @IBAction func cancelBtnPressed(_ sender: Any) {
          dismiss(animated: true, completion: nil)
      }
  
      @IBAction func saveBtnPressed(_ sender: Any) {
  
          let firstname = firstNameText.text ?? ""
          let middlename = middleNameText.text ?? ""
          let lastname = lastNameText.text ?? ""
  
          let formData = ChildInfo(cFirstName: firstname, cMiddleName: middlename, cLastName: lastname)
          self.navigationController?.popViewController(animated: true)
  
           formDelegate.saveInfoBlock(form: formData)
  
          saveInfoBLock()
      }
  
      func saveInfoBLock() {
          print("Saving Info")
  
          dismiss(animated: true, completion: nil)
  
      }
  
  }
  </code></pre>
  
  <p>Heres my struct that I don't properly use</p>
  
  <pre><code>struct ChildInfo {
  
      var childFirstName: String?
      var childMiddleName: String?
      var childLastName: String?
  
  
      var childsMadeUpName: String = ""
  
      init(cFirstName: String, cMiddleName: String, cLastName: String) {
          self.childFirstName = cFirstName
          self.childMiddleName = cMiddleName
          self.childLastName = cLastName
      }
  
  }
  </code></pre>
  
  <p>and lastly my tableviewcell</p>
  
  <pre><code>class ChildInfoTableViewCell: UITableViewCell {
  
      @IBOutlet weak var formText: UITextField!
      @IBOutlet weak var formLabel: UILabel!
  
  
  
      override func awakeFromNib() {
          super.awakeFromNib()
          // Initialization code
      }
  
      override func setSelected(_ selected: Bool, animated: Bool) {
          super.setSelected(selected, animated: animated)
  
          // Configure the view for the selected state
      }
  
  }
  </code></pre>
  
  <p>Once the delegate protocol gets passed. What would a put in the printtableviewcontroller to make the data show? I had someone help me on here, but It was all programmatically and I'm no that advanced yet.</p>