I'm trying to request the user's location while using the app. I have added NSLocationWhenInUseUsage to my plist. The app doesn't crash or otherwise show any errors. The app just starts and there isn't any popup to request permission of the user.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.requestWhenInUseAuthorization()
I also added this function to my code:
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
println(locations)
Also, I'm not an adept programmer, so a simpler answer would be better.