命令因信号而失败:分段错误:更新到 Xcode 7.1 后为 11
Command failed due to signal: Segmentation fault: 11 after update to Xcode 7.1
我正在为 ios 9 开发一个应用程序。自从我更新到 7.1 版本后,我遇到了这个错误:
命令因信号而失败:分段错误:11
查看代码,我发现这段代码导致了这个错误:
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if !(annotation is ADBaseAnnotation){
print("No es ADBaseAnnotation",terminator:"\n")
return nil
}
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier((annotation as! ADBaseAnnotation).getReuseId())
if let normal = annotation as? NormalParking {
//anView = normal.getAnnotationView(annotation, reuseIdentifier: normal.getReuseId())
} else if let hightlight = annotation as? HightLightParking{
//anView = hightlight.getAnnotationView(annotation, reuseIdentifier: hightlight.getReuseId())
}
return anView
}
错误是由注释行引起的。请帮助
这是编译器真正失败的问题,还是像正常编译后仍然会突出显示错误代码行?当编译器对我编写的代码感到困惑并且无法编译并在内部崩溃时,我经常遇到这种情况。如果是这种情况,您可以在编译日志中找到更详细的信息。通常这是我自己的错,但编译器仍然太新,无法提供良好的反馈或以优雅的方式处理这种情况。
我不认识确切的问题,但我注意到有关您的代码的一些事情。以下内容对我来说很有趣:
if let normal = annotation as? NormalParking {
anView = normal.getAnnotationView(annotation, reuseIdentifier: normal.getReuseId())
}
你为什么不使用相同的强制转换变量:
if let normal = annotation as? NormalParking {
anView = normal.getAnnotationView(normal, reuseIdentifier: normal.getReuseId())
}
施法后也一样,实际上根本不需要施法。
例如:
guard let annotation = annotation as? ADBaseAnnotation else {
print("No es ADBaseAnnotation",terminator:"\n")
return nil
}
if annotation is NormalParking || annotation is HightLightParking {
return annotation.getAnnotationView(annotation, reuseIdentifier: annotation.getReuseId())
}
return mapView.dequeueReusableAnnotationViewWithIdentifier(annotation).getReuseId())
我假设 ADBaseAnnotation 是共享基础 class 定义 getReuseId() 并且您的 Parking 实现覆盖 getReuseId()
我正在为 ios 9 开发一个应用程序。自从我更新到 7.1 版本后,我遇到了这个错误: 命令因信号而失败:分段错误:11
查看代码,我发现这段代码导致了这个错误:
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if !(annotation is ADBaseAnnotation){
print("No es ADBaseAnnotation",terminator:"\n")
return nil
}
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier((annotation as! ADBaseAnnotation).getReuseId())
if let normal = annotation as? NormalParking {
//anView = normal.getAnnotationView(annotation, reuseIdentifier: normal.getReuseId())
} else if let hightlight = annotation as? HightLightParking{
//anView = hightlight.getAnnotationView(annotation, reuseIdentifier: hightlight.getReuseId())
}
return anView
}
错误是由注释行引起的。请帮助
这是编译器真正失败的问题,还是像正常编译后仍然会突出显示错误代码行?当编译器对我编写的代码感到困惑并且无法编译并在内部崩溃时,我经常遇到这种情况。如果是这种情况,您可以在编译日志中找到更详细的信息。通常这是我自己的错,但编译器仍然太新,无法提供良好的反馈或以优雅的方式处理这种情况。
我不认识确切的问题,但我注意到有关您的代码的一些事情。以下内容对我来说很有趣:
if let normal = annotation as? NormalParking {
anView = normal.getAnnotationView(annotation, reuseIdentifier: normal.getReuseId())
}
你为什么不使用相同的强制转换变量:
if let normal = annotation as? NormalParking {
anView = normal.getAnnotationView(normal, reuseIdentifier: normal.getReuseId())
}
施法后也一样,实际上根本不需要施法。
例如:
guard let annotation = annotation as? ADBaseAnnotation else {
print("No es ADBaseAnnotation",terminator:"\n")
return nil
}
if annotation is NormalParking || annotation is HightLightParking {
return annotation.getAnnotationView(annotation, reuseIdentifier: annotation.getReuseId())
}
return mapView.dequeueReusableAnnotationViewWithIdentifier(annotation).getReuseId())
我假设 ADBaseAnnotation 是共享基础 class 定义 getReuseId() 并且您的 Parking 实现覆盖 getReuseId()