title: Pass data from Realm between Viewcontrollers
body: <p>I have saved data from a form in my realm database (i.e . name, age, address, etc) and I want to pass those values to various viewcontrollers throughout my project. </p>
  
  <p>In one of my viewcontrollers there is a tableview that accesses some of that data from an array and populates the cell. What I would like to do is when the user taps the cell, the data from my realm gets passed to various labels and textfields in the detail viewcontroller. I read earlier that all I need is to use prepareForSegue, but I'm not sure of the proper way to access the values so they go to the destinationviewcontroller. I will attaxh code snippits of my view controllers so you can see where I am currently.</p>
  
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      let request = try! Realm().objects(RenterRequest.self).sorted(byKeyPath: "requestAddress")
  
      if segue.identifier == "HistoryData" {
          let renterMaintenanceHistory = segue.destination as? RenterMaintenanceHistory
          renterMaintenanceHistory?.renterHIstoryAddress.text = request.description
      }
  }
  
  import UIKit
  import RealmSwift
  
  class RenterMaintenanceHistory: UIViewController {
  
      var request = RenterRequest()
  
      @IBOutlet weak var RenterHistoryPriority: UITextField!
      @IBOutlet weak var renterHistoryType: UITextField!
      @IBOutlet weak var renterHIstoryAddress: UITextField!
      @IBOutlet weak var renterHistoryRoom: UITextField!
      @IBOutlet weak var renterHIstoryProblemDescription: UITextView!
      @IBOutlet weak var renterHistoryPreferredTimeAndDate: UITextField!
      @IBOutlet weak var renterHistoryPets: UISwitch!
      @IBOutlet weak var renterHistoryAuthorizedEntry: UISwitch!
      @IBOutlet weak var renterHIstoryPreferredContactNumber: UITextField!
      @IBOutlet weak var renterHistoryPreviouslyReported: UISwitch!
  
      var renterHistoryAddress: String?
  
      override func viewDidLoad() {
          super.viewDidLoad()   
      }
  
      override func viewWillAppear(_ animated: Bool) {
          renterHIstoryAddress.text = renterHistoryAddress
      }
  }
  </code></pre>
  
  <p>when I run the code and try to access the property I get the Unexpectedly found nil while unwrapping an Optional value . Should I access the realm.objects function through the model to retrieve the values?</p>