不知道是什麼問題。我對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