NKLocation 1.0.0

NKLocation 1.0.0

NandaKishore维护。



  • 作者:
  • Nanda

NKLocation

简单:一行代码获取位置(经纬度)

步骤1:在ViewDidLoad中

    override func viewDidLoad() {
                super.viewDidLoad()
                // Do any additional setup after loading the view.
                // step: 1 : Start your location update
                LocationSingleton.sharedInstance.startUpdatingLocation()
    }

步骤2

 In Button Action Add This lines
 
    func getLatAndLong() {
    
                 LocationSingleton.sharedInstance.startUpdatingLocation()
                 let location = LocationSingleton.sharedInstance.lastLocation
                 
                 
                 if location != nil {
                 
                 print(location!.coordinate.latitude)
                 print(location!.coordinate.longitude)
                 }
     }

步骤3:提供位置隐私设置

In Info.plist Paste this code

<key>NSLocationAlwaysUsageDescription</key>
<string>App would like to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string> App would like to use your location</string>






~~~~~~~~~~~~~~~~ Thank you ~~~~~~~~~~~~~~~~~~~~