我收到了几个崩溃的Xcode组织者,但我不能找到它的根本原因。将是很好的,如果有人可以看看它,并给予他的想法...
...下面是getter的代码
// most recent location received
var _mostRecentLocationReceived : CLLocation = CLLocation(latitude: 0, longitude: 0)
var mostRecentLocationReceived : CLLocation {
set (newValue) {
_mostRecentLocationReceived = newValue
}
get {
// check if someone already set the variable
if ((_mostRecentLocationReceived.coordinate.latitude != 0.0)
&& (_mostRecentLocationReceived.coordinate.longitude != 0.0))
{
// yes, so return it
return _mostRecentLocationReceived
} else {
// not set so far, provide a helper value
// first atempt, the current location from location manager
if WTS.unique.WTS_LocationManager != nil {
if WTS.unique.WTS_LocationManager!.location != nil {
return WTS.unique.WTS_LocationManager!.location!
}
}
// second atempt the last stored center of the map
return CLLocation(latitude: WaysMapOnScreenLastCenter.latitude,
longitude: WaysMapOnScreenLastCenter.longitude)
}
}
}
Crash将此行标记为原因
if ((_mostRecentLocationReceived.coordinate.latitude != 0.0)
&& (_mostRecentLocationReceived.coordinate.longitude != 0.0))
...任何想法都欢迎!!
哈代
1条答案
按热度按时间y4ekin9u1#
下面是最终的修复,使用HangarRash和matt的答案