这是我的locationManager函数,有人可以告诉我为什么我收到错误:'致命错误:在解包时意外发现nil可选值'?
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation: CLLocation = locations[0] as CLLocation
CLGeocoder().reverseGeocodeLocation(userLocation) { (placemarks, error) -> Void in
if (error != nil) {
print(error)
} else {
if placemarks!.count > 0 {
if let pm = placemarks![0] as CLPlacemark! {
print(pm)
self.locationButtonLabel.text = "\(pm.subLocality!),\(pm.locality!)"
}
}
}
}
}