Search code examples
iosxcodeswiftgeolocation

CLLocationDegrees to String variable in Swift


Given that the code

var latitude = userLocation.coordinate.latitude

returns a CLLocationDegrees Object, how can I store the value in to a variable so that I can apply it as the text of a label.

I can print the variable to the console without any issues but obviously that doesn't help me too much!

Looking through the valuable options through the autocomplete i see there is a description;

var latitude = userLocation.coordinate.latitude.description

But this is returning me null?

Thanks


Solution

  • You can turn it to a String using this code:

    var oneString = String(userLocation.coordinate.latitude)