title: swift ios - How to run function in ViewController from AppDelegate
body: <p>I am trying to run a function in certain <code>ViewController</code> using <code>AppDelegate</code></p>
  
  <pre><code>func applicationDidBecomeActive(_ application: UIApplication) {
          ViewController().grabData()
  }
  </code></pre>
  
  <p>But somehow the function does not seem to run at all when the app has become active after entering the app from the background.</p>
  
  <p>The function looks like this</p>
  
  <pre><code>func grabData() {
          self._DATASERVICE_GET_STATS(completion: { (int) -&gt; () in
              if int == 0 {
                  print("Nothing")
              } else {
                  print(int)
  
                  for (_, data) in self.userDataArray.enumerated() {
                      let number = Double(data["wage"]!)
                      let x = number!/3600
                      let z = Double(x * Double(int))
                      self.money += z
                      let y = Double(round(1000*self.money)/1000)
  
                      self.checkInButtonLabel.text = "\(y) KR"
                  }
  
                  self.startCounting()
                  self.workingStatus = 1
              }
          })
      }
  </code></pre>
  
  <p>And uses this var</p>
  
  <pre><code>var money: Double = 0.000
  </code></pre>
  
  <p>What have I missed?</p>
  
  <p><strong>Thanks!</strong></p>