【发布时间】:2015-09-16 16:42:37
【问题描述】:
我收到了这个错误,我不知道如何解决它。我已经浏览了这里的所有答案,但我尝试的任何方法都不起作用。这是我的代码:
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { (placemarks, error ) -> Void in
var title = ""
if (error == nil) {
if let p = CLPlacemark(placemark: placemarks![0] as! CLPlacemark){
var subThoroughfare:String = ""
var thoroughfare:String = ""
if p.subThoroughfare != nil{
subThoroughfare = p.subThoroughfare
}
if p.thoroughfare != nil{
thoroughfare = p.thoroughfare
}
title = "\(subThoroughfare) \(thoroughfare)"
}
}
if title == ""{
title = "Added \(NSDate())"
}
错误在线:
if let p = CLPlacemark(placemark: placemarks![0] as! CLPlacemark){
条件绑定的初始化程序必须具有可选类型,而不是“CLPlacemark”
【问题讨论】:
-
不是抨击或任何东西,但这应该与
Fatal error: unexpectedly found nil while unwrapping an Optional value一起出现在“不言自明的控制台消息万神殿中,可以准确地告诉您代码 (TM) 出了什么问题”