title: How to execute a task after location permission granted ios
body: <p>I'm trying to set up an on boarding where I'm asking the user for a few permissions including: Location, Notifications and Camera. I have 3 different View Controllers set up, each asking for one of the permissions and explaining why. On each of the view controllers I have a button at the bottom that says "Grant Permission". </p>
  
  <p>When the user clicks the button I want the permission dialogue to pop up, and once the user clicks allow I want to transition to the next view controller. </p>
  
  <p>Here is what I have right now: </p>
  
  <pre><code>class OnboardingStep2:UIViewController{
  
      override func viewDidLoad() {
          self.view.backgroundColor = StyleKit.orangeWhite()
      }
  
      @IBAction func getPermission(sender: AnyObject) {
  
          dispatch_sync(dispatch_get_main_queue()) {
              let locManager = CLLocationManager()
              locManager.requestAlwaysAuthorization()
  
          }
  
          if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.Authorized) {
              self.performSegueWithIdentifier("goToStep3", sender: self)
          }
  
      }
  }
  </code></pre>
  
  <p>I've tried using dispatch to queue up the tasks, but when using async the permission dialogue pops up and then immediately it closes because the authorization check is run (I'm assuming). Using dispatch_sync, the dialogue is never shown.</p>
  
  <p>What is the best way to do this, I want the permission dialogue to pop up first and once the user clicks allow i want to segue. </p>