【发布时间】:2015-09-19 11:35:42
【问题描述】:
我正在尝试将我的 swift 1.2 应用程序转换为 2.0。我已经尝试了一些我在互联网上找到的修复方法,但它不起作用。
错误:Converting to Swift 2.0 - Cannot Subscript a value of type '[CLPlacemark]?'
代码:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
CLGeocoder().reverseGeocodeLocation(manager.location!, completionHandler: {(placemarks, error)->Void in
if (error != nil)
{
print("Error: " + error!.localizedDescription)
return
}
if placemarks!.count > 0
{
let pm = placemarks[0] as! CLPlacemark
self.displayLocationInfo(pm)
}
else
{
print("Error with the data.")
}
})
}
【问题讨论】: