I tried something. I think you want to get latitude, longitude and timestamp.
Below you will find an example for latitude and longitude.
import UIKit import CoreLocation class ViewController: UIViewController, CLLocationManagerDelegate { var locationManager: CLLocationManager! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func showLocation(_ sender: Any) { locationManager = CLLocationManager() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestAlwaysAuthorization() if(CLLocationManager.locationServicesEnabled()){ locationManager.startUpdatingLocation() } locationManager.stopUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let userLocation:CLLocation = locations[0] as CLLocation print("user latitude = \(userLocation.coordinate.latitude)") print("user longitude = \(userLocation.coordinate.longitude)") } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print("Error \(error)") } }
To get the current time, you can use something like this:
let date = NSDate() print(date)
The result for both consoles should look something like this:
2017-12-17 21:45:39 +0000 user latitude = 37.3322499 user longitude = -122.056264
(Time looks like this in my example, because I'm from the EU, but you can convert it to what you want)
You can add this to a separate view and bring it to the forefront with
view.bringSubview(toFront: YourView)
I hope this will be helpful!
source share