title: Swift NavigationBar Press "Back" to get values, why?
body: <p>I am using some values to perform some calculations. For testing purposes I show in Label1 a value as string, since it is stored as a string and in Label2 I show a casted value as a Double since I need them at the end as doubles for my calculations.</p>
  <p>The weird thing is, that when I access the ViewController the first time it doesn't show any values. But if I go back and klick on it again using the navigation controller it actually works. But I need the values right away cause my original intention is as I said, not showing some labels but rather making some calculations with it.</p>
  <p>I made a little gif to show you what the problem is but I have problem with adding photos. Basically what happens is, that I click on the ViewController with the labels and nothing is showed. I go back and press again and the values will be showed in the labels.</p>
  <p>Why is that and how can it be showed right away/ used for calculations right away</p>
  <p>Thanks for the help. :)</p>
  <pre><code>class AHPfinalPreferencesViewController: UIViewController {
  
    var ahpPrios = [AHPPriorityStruct]()
      let decoder = JSONDecoder()
  
      @IBOutlet weak var label1: UILabel!
      @IBOutlet weak var label2: UILabel!
      
     
      let ajkpXc = globaLajkpXc
      let ajkpXijr = globaLajkpXijr
  
      let valueA = globaLajkpXc
      let valueB = Double(globaLajkpXijr)
  
  
   override func viewWillAppear(_ animated: Bool) {
           super.viewWillAppear(animated)
          UserService.ahpPref(for: User.current) { (ahpPrios) in
                  self.ahpPrios = ahpPrios
                  print(&quot;This is our AHP PRIOS&quot;, ahpPrios)
                  
  
                  for ahpPrio in ahpPrios {
                    print(ahpPrio)
                  }
                
                  print(&quot;this is the global ajk. &quot;, self.ajkpXc)
          }
           
              
       }
          
      
      override func viewDidLoad() {
          super.viewDidLoad()
  
  // Mark: - Get Data
        
               label1.text = valueA
               label2.text = &quot;\(String(describing: valueB))&quot;
  
          
  // MARK: - Set Values for calculation
          
  //        setValues()
  //        ahpCalculation()
          
      }
    }
  
  </code></pre>
  <p>Could it be because of the globalVariables? I know that it is not the right way to do it but for my purposes its absolutely &quot;okay&quot;</p>
  <pre><code>import Foundation
  import FirebaseAuth.FIRUser
  import FirebaseDatabase
  import FirebaseUI
  import FirebaseAuth
  import CodableFirebase
  
  var globaLajkpXc: String = String()
  var globaLajkpXijr: String = String()
  var globaLajkpXqpa: String = String()
  
  
  struct UserService {
  
  static func ahpPref(for user: User, completion: @escaping ([AHPPriorityStruct]) -&gt; Void) {
         
          
          let ref = Database.database().reference().child(&quot;AHPRatings&quot;).child(user.uid)
          
          
                  ref.observe(DataEventType.value, with: { snapshot in
                      guard let value = snapshot.value else { return }
                      do {
                          let ahpPrios = try FirebaseDecoder().decode(AHPPriorityStruct.self, from: value)
                          print(ahpPrios)
                          
                          
                          // MARK: - lets store the values in the actual constants :)
                          
                          let ajkpXc = ahpPrios.ajkpXc
                          let ajkpXijr = ahpPrios.ajkpXijr
                          let ajkpXqpa = ahpPrios.ajkpXqpa
  
                               globaLajkpXc = ajkpXc ?? &quot;no Value&quot;
                               globaLajkpXijr = ajkpXijr ?? &quot;no Value&quot;
                               globaLajkpXqpa = ajkpXqpa ?? &quot;no Value&quot;
  
  } catch let error {
                          print(error)
                      }
                  })
          
       
          
            }
  
    }  
  
  
    [1]: https://i.stack.imgur.com/VKxaE.png
  </code></pre>