title: How to retrieve data save in Model Class Swift 3
body: <p>I am trying to retrieve data saved in the Model file from View Controller 2, but I'm getting zeroes.  How can I save and retrieve data in Model class from any View Controller in my project?</p>
  
  <p>Model.swift:</p>
  
  <pre><code>class Model {
  
      var hoursTaken = 0.0
      var currentGPA = 0.0
      //var classArray: [String]
  
      func saveGPA(GPA: Double) {
          currentGPA = GPA
      }
  
      func returnGPA() -&gt; Double {
          return currentGPA
      }
  
      func saveHoursTaken(HoursTaken: Double) {
          hoursTaken = HoursTaken
      }
  }
  </code></pre>
  
  <p>In View Controller 1:</p>
  
  <pre><code>var model = Model()     
  
  func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
      if pickerView.tag == 1 {
          let hourstaken = Double(choices[row])
          print(hourstaken!)
          hoursTakenText.text = choices[row]
          model.saveHoursTaken(HoursTaken: hourstaken!)
  
          //print(model.hoursTaken)
      } 
      else if row &lt; 12 {
          let currentGPA = Double(choices2[row])
          print(currentGPA!)
          model.saveGPA(GPA: currentGPA!)
          GPATextField.text = choices2[row]
      }
  
      subView.isHidden = true
      subview2.isHidden = true
  }
  </code></pre>
  
  <p>In View Controller 2 prints 0.0:</p>
  
  <pre><code>import Foundation
  import UIKit
  
  class ThirdViewController: UIViewController {
  
      var model = Model()
  
      @IBAction func testButton(_ sender: UIButton) {
          print("Test Button Pressed")
          let a = model.returnGPA()//prints 0.0
          print(a)    
      }
  
      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>