Hi had lot of trouble in understanding the declaration part in swift programming.
I have line of code CLLocationCoordinate2D myCoordinate = myLocation.coordinate;
As same as I declared in Swift programming but I'm getting error
var location1:CLLocation! = locationManager1.location
var coordinate1:CLLocationCoordinate2D = location1.coordinate
fatal error: Can't unwrap Optional.None
the location1
can be nil
, and you have to check whether or not it is nil
before you access to its proprties, like e.g. this:
let locationManager1: CLLocationManager // your location manager
// ...
if let location1: CLLocation = locationManager1.location {
var coordinate1: CLLocationCoordinate2D = location1.coordinate
// ... proceed with the location and coordintes
} else {
println("no location...")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With