消息发送到解除分配的实例 - 用僵尸分析

时间:2012-08-13 09:57:49

标签: ios crash sigabrt nszombie

我的应用程序崩溃,消息“...发送到地址处的解除分配的实例...”。所以,我用僵尸乐器分析了应用程序,我在下面提供了导致崩溃的代码片段。 我还没有发现导致此错误的情况。

(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
if ([view.annotation isKindOfClass:[MKUserLocation class]]) {
}
else {
    CustomAnnotation *ann = (CustomAnnotation *) view.annotation;
    if (ann.annotationType == BusAnnotationType) {
        NSLog(@"accessory button tapped for annotation %@", view.annotation);
        BusInfoViewController *viewController = [[BusInfoViewController alloc] initWithNibName:@"BusInfoViewController" bundle:nil];
        BusForStation *bus = [self getBusWithId:[(CustomAnnotation *)view.annotation ID]];
        viewController.currentBus = bus;
        [self.navigationController pushViewController:viewController animated:YES];
        [viewController release];
    }
}

分析工具获得91.4%[self.navigationController pushViewController:viewController animated:YES];

有谁知道可能是什么问题?

3 个答案:

答案 0 :(得分:3)

我认为我在没有转换为ARC的情况下解决了类似的问题。我有一个navigationController,我的viewController包含一个mapView。加载视图后,我调用setRegion:myregion animated:YES。如果在动画完成之前单击“返回”,则mapView会在[respondsToSelector:]消息上引发“发送到解除分配实例的消息”错误。我通过在释放myMapView之前设置myMapView.delegate = nil来修复此问题。

答案 1 :(得分:1)

考虑使用ARC(自动参考计数)。 Xcode可以使用菜单"Edit" ➞ "Refactor" ➞ "Convert to Objective-C ARC…"几乎完全自动转换您的项目。手动管理内存的原因很少。

您也可以尝试运行静态分析器(菜单"Product" ➞ "Analyze")。

答案 2 :(得分:0)

我认为你遇到的问题是你将viewController推送到视图后直接释放它。此外,如果您已经为setCurrentBus(在BusInfoViewController中)完成了自己的实现,那么问题可能存在。