title: How to call a function every time user opens application
body: <p>I want to call the function named update every time user taps my app's icon and open it. How would I do that? Which method fires that I can override whenever the app launches no matter is killed from background or user pressed the home button.</p>
  
  <pre><code> import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var label: UILabel!
  
      @IBOutlet weak var button: UIButton!
  
      @IBOutlet weak var labeltwo: UILabel!
  
      var NSDateDefalt = NSUserDefaults.standardUserDefaults()
      var date : NSDate?
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          date = NSUserDefaults.standardUserDefaults().objectForKey("yourKey") as? NSDate
          label.text = "\(date)"
          update()
      }
  
  
      @IBAction func buttona(sender: AnyObject) {
          date = NSDate()
          label.text = "\(date)"
  
          NSUserDefaults.standardUserDefaults().setObject(NSDate(), forKey:"yourKey")
      }
  
  
  
      func update(){
          let now = NSDate()
          let seconds = now.timeIntervalSinceDate(date!)
          labeltwo.text = "\(seconds))"
      }
  
  }
  </code></pre>
  
  <p>Update: I implemented in my App Delegate</p>
  
  <pre><code> func applicationWillEnterForeground(application: UIApplication) {
          ViewController().update()     
      }
  </code></pre>