CLLocation Timestamp is always zero


CLLocation Timestamp is always zero



The CLLocation timestamp is always zero on iPhone 6+, IOS 11.4, Xcode 9.4.1.



Latitude: 30.598748
Longitude: -97.820877
Altitude: 308.921658
HAccuracy: 10.000000
VAccuracy: 4.000000
Timestamp: 0.000000 <======



Is there some setting that will give me accurate timestamp? Here is the code that prints it:


print("Latitude: (String(format: "%.6f", location.coordinate.latitude))")
print("Longitude: (String(format: "%.6f", location.coordinate.longitude))")
print("Altitude: (String(format: "%.6f", location.altitude))")
print("HAccuracy: (String(format: "%.6f", location.horizontalAccuracy))")
print("VAccuracy: (String(format: "%.6f", location.verticalAccuracy))")
print("Timestamp: (String(format: "%.6f", location.timestamp as CVarArg))")




1 Answer
1



The timestamp is an object of type Date. It should print with this:


timestamp


Date


print("Timestamp: (String(format: "%@", location.timestamp))")





Or simply: print("Timestamp: (location.timestamp)").
– rmaddy
Jul 1 at 20:04


print("Timestamp: (location.timestamp)")





@rmaddy Thank you. I don't trust my Swift print skills since it started giving all those warnings about string interpolation.
– nevan king
Jul 1 at 21:18


print





Thanks for seeing that...copy and paste always gets me.
– Tim
Jul 2 at 15:29






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?