/ Como a longitude e a latitude de exibição em rótulos-swift - swift

Como exibir longitude e latitude em rótulos - swift - swift

Eu estou tentando exibir a longitude e latitude em 2 rótulos chamados longitude e latitude, mas eu não estou tendo nenhum resultado.

import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate{

@IBOutlet weak var longitude: UILabel!
@IBOutlet weak var latitude: UILabel!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
if (CLLocationManager.locationServicesEnabled()) {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
} else {
println("Location services are not enabled");
}
}
// MARK: - CoreLocation Delegate Methods
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
locationManager.stopUpdatingLocation()
removeLoadingView()
if ((error) != nil) {
print(error)
}
}

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
var locationArray = locations as NSArray
var locationObj = locationArray.lastObject as CLLocation
var coord = locationObj.coordinate
longitude.text = coord.longitude
latitude.text = coord.latitude

}
}

Eu estou tendo erros em longitude.text = coord.logitude e mesmo para a segunda tabela diz que não pode converter em string. Eu sou novo em Swift.

Respostas:

2 para resposta № 1

Você converte os números em seqüências de caracteres, como com:

longitude.text = "(coord.longitude)"