I have this code on my view controller but this not working:
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var location: CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
location=CLLocationManager()
location.delegate = self
location.desiredAccuracy=kCLLocationAccuracyBest
location.startUpdatingLocation()
}
func locationManager(location:CLLocationManager, didUpdateLocations locations:AnyObject[]) {
println("locations = \(locations)")
label1.text = "success"
}
I have the permisions how I read in other post. but I don't obtain never, no println..
Thanks!!
Following are the simple steps for getting user location in Swift 3
1) First add this line in plist file with description
2) Add CoreLocation.framework in your project(Under section Build Phases-> Link Binary With Library)
3) In AppDelegate class
4) Create locationManager Object as follows
5) Write following code in didFinishLaunchingWithOptions
6) Confirm CLLocationManagerDelegate delegate like as follows
7) Write CLLocationManagerDelegate delegate method for getting user location