Inside Location Services
I allow my App to always use location. In viewDidLoad I created a timer which calls my method every 2 seconds:
println("---\(locationManager.location)")
In the beginning I get ---nil
, but when I go to the settings and change access to always, and then get back to the app again, I immediately get:
---<+50.06689474,+19.92923662> +/- 165.00m (speed -1.00 mps / course -1.00) @ 28.05.2015, 13:00:39 Czas środkowoeuropejski letni
But once it is printed there is still: ---nil
. Why?
This is how I setup locationManager
:
private let locationManager = CLLocationManager()
in viewDidLoad()
I call the method:
private func setupLocationManager() {
locationManager.delegate = self
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: Selector("printLocation"), userInfo: nil, repeats: true)