不知道是什么问题。我对swift和iOS8非常陌生。但总的来说,我在iOS7中没有发现CLLocationManager的问题。我已经提出了许多警示性的ifs和check以及nils,但是我一直在收到这个错误。请帮忙!iOS didUpdateLocations抛出错误iOS 8.0 Swift
所以,上的一个按钮的触摸动作,我开始喜欢这个外景经理,与imagepicker相机一起 -
//Start the location manager
self.captureLocationManager?.requestWhenInUseAuthorization()
self.captureLocationManager?.delegate = self
self.captureLocationManager?.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
self.captureLocationManager?.startUpdatingLocation()
self.captureLocationManager?.distanceFilter = 40
....
{image picker code}
这是我didUpdateLocations
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!){
if locations.count > 0 {
var latestLocation = locations[locations.count-1] as CLLocation
if !self.captureGeoCoder.geocoding {
self.captureGeoCoder.reverseGeocodeLocation(latestLocation, completionHandler: { (placeMarks:[AnyObject]!, error: NSError!) -> Void in
if error == nil{
if placeMarks != nil{
self.captureLocationPlaceMark = placeMarks[0] as CLPlacemark
println(self.objMomentModel.captureLocationPlaceMark.name)
self.captureLocationManager?.stopUpdatingLocation()
self.captureLocationManager = nil
}
else{
println("0 placemarks!")
}
}
else{
println("Oops, there was an error in reverseGeoCodeLocation!")
}
})
}
}
}
但我的代码掷骰子代码列于
self.captureLocationPlaceMark = placeMarks[0] as CLPlacemark
与像一些奇怪的错误:
(lldb)
这可能是无关紧要的,但它可能不是......在任何情况下,这一行肯定是错误的:'如果错误== nil' - 除非placeMarks为零,否则你不应该检查错误。试着去除这部分条件,看看事情是否有所改善。如果他们不这样做,删除它仍然是正确的。 – matt 2014-08-30 23:14:17
为什么它错了?如果有错误,我不应该停止继续执行其他代码吗? – 2014-08-30 23:27:48
什么是错误?你只能放入lldb提示符。 – 2014-08-30 23:56:06