title: How to delay the return to the calling function swift
body: <p>In my application the user can press a button. That in turn leads to a function call which is showed below:</p>
  
  <p><strong>In ViewController.Swift</strong></p>
  
  <pre><code>@IBAction func pickMeUpButton(sender: AnyObject) {
  
      sendPushNotificationController().sendPushNotification("sendRequest",userInfo: defaults.stringForKey("x73")!, userInf23: defaults.stringForKey("x23")! )
  
      locationController.getLocationForShortTime() // --&gt; here i want the timer to finish the 5 seconds before proceeding
  
      activityIndicator.center = self.view.center
  
      activityIndicator.startAnimating()
  
      self.view.addSubview(activityIndicator)
  
      //activityIndicator.stopAnimating()
  
  }
  </code></pre>
  
  <p>And this is the class function where the call is being made to</p>
  
  <p><strong>In getUserLocation.swift</strong></p>
  
  <pre><code>func initManager(){
  
      locationManager = CLLocationManager()
      locationManager.delegate = self
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
      locationManager.requestAlwaysAuthorization()
      locationManager.startUpdatingLocation()
  }
  
  func getLocationForShortTime(){
  
      initManager()
      timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: "stopGettingLocation", userInfo: nil, repeats: false)
  
  }
  
  func stopGettingLocation(){
  
      locationManager.stopUpdatingLocation()
  }
  </code></pre>
  
  <p>So this will make the application get the users location for 5 seconds and then the timer will stop the updates. What i want to do is when the five seconds has elapsed and the location update stops THEN i would like the calling function to proceed to next line. </p>
  
  <p>I though of some solutions using boolean, but it is not a nice solution. Im thinking there might be a better way to do this?  </p>