Ios CLLocation至swift中的CLLOCATIONCoordinated2D

Ios CLLocation至swift中的CLLOCATIONCoordinated2D,ios,swift,Ios,Swift,Hi在理解swift编程中的声明部分时遇到了很多困难。 我有一行代码CLLocationCoordinate2D myCoordinate=myLocation.coordinate 和我在Swift编程中声明的一样,但我得到了一个错误 var location1:CLLocation! = locationManager1.location var coordinate1:CLLocationCoordinate2D = location1.coordinate 致命错误:无法展开可选。无位

Hi在理解swift编程中的声明部分时遇到了很多困难。 我有一行代码
CLLocationCoordinate2D myCoordinate=myLocation.coordinate
和我在Swift编程中声明的一样,但我得到了一个错误

var location1:CLLocation! = locationManager1.location
var coordinate1:CLLocationCoordinate2D = location1.coordinate

致命错误:无法展开可选。无

位置1
可以是
nil
,在访问其属性之前,您必须检查它是否为
nil
,例如:

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...")
}

你犯了什么错误?
location1
的声明在哪里?我已经编辑了这个问题..你能检查一下它吗
locationManager1
?CLLocationManager@Kreiri