title: NSLocation doesn't wait for me to click allow
body: <p>When I run the code, the window pops asking for permission to use location but disappears almost immediately, not giving the user a chance to click "Allow". Is there a way to force this action before proceeding?</p>
  
  <pre><code>import UIKit
  import MapKit
  import CoreLocation
  
  class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{
  
  var map:MKMapView?
  var manager:CLLocationManager!
  
  convenience init(frame:CGRect){
      self.init(nibName: nil, bundle: nil)
      self.view.frame = frame
  
      self.map = MKMapView(frame: frame)
      self.map!.delegate = self
  
      self.view.addSubview(self.map!)
  
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // Core Location
      manager = CLLocationManager()
      manager.delegate = self
      manager.desiredAccuracy = kCLLocationAccuracyBest
  
  }
  
  func locationManager(manager: CLLocationManager!,
      didChangeAuthorizationStatus status: CLAuthorizationStatus){
  
          print("The authorization status of location services is changed to: ")
  
          switch CLLocationManager.authorizationStatus(){
          case .Denied:
              println("Denied")
          case .NotDetermined:
              println("Not determined")
          case .Restricted:
              println("Restricted")
          default:
              println("Authorized")
          }
  
  }
  
  func displayAlertWithTitle(title: String, message: String){
      let controller = UIAlertController(title: title,
          message: message,
          preferredStyle: .Alert)
  
      controller.addAction(UIAlertAction(title: "OK",
          style: .Default,
          handler: nil))
  
      presentViewController(controller, animated: true, completion: nil)
  
  }
  
  override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)
  
      if CLLocationManager.locationServicesEnabled(){
          switch CLLocationManager.authorizationStatus(){
          case .Denied:
              displayAlertWithTitle("Not Determined",
                  message: "Location services are not allowed for this app")
          case .NotDetermined:
                  manager.requestWhenInUseAuthorization()
                  manager.startUpdatingLocation()
          case .Restricted:
              displayAlertWithTitle("Restricted",
                  message: "Location services are not allowed for this app")
          default:
              println("Default")
          }
  
      } else {
          println("Location services are not enabled")
      }
  
  }
  
  
  func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]) {
  
      var userLocation:CLLocation = locations[0] as! CLLocation
      var latitude:CLLocationDegrees = userLocation.coordinate.latitude
      var longitude:CLLocationDegrees = userLocation.coordinate.longitude
      var latDelta:CLLocationDegrees = 1.0
      var lonDelta:CLLocationDegrees = 1.0
  
      var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)
      var location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
      var region:MKCoordinateRegion = MKCoordinateRegionMake(location, span)
      map!.setRegion(region, animated: true)
      manager.stopUpdatingLocation()
  
  }
  </code></pre>