objc_msgSend crash:我怎样才能找到哪里?

发布于 2024-11-23 19:49:07 字数 2879 浏览 1 评论 0原文

启用 nszombies 在此调试日志中是否有任何人可以看到的其他信息,我可以用它来查找问题?

(gdb) bt  
0  0x30b7eca4 in objc_msgSend ()  
1  0x36179302 in -[MKMapView annotationContainer:viewForAnnotation:] ()  
2  0x36178f94 in -[MKAnnotationContainerView _addViewForAnnotation:] ()  
3  0x361a2faa in -[MKAnnotationContainerView userLocationAnnotationWillShow] ()  
4  0x3619fcbe in -[MKMapView(UserPositioningInternal) _runPositioningChange] ()  
5  0x3619da8c in -[MKMapView(UserPositioningInternal) _startPositioningChange:] ()  
6  0x361a1050 in -[MKMapView(UserPositioningInternal) locationManagerUpdatedLocation:] ()  
7  0x365cff02 in -[NSObject(NSObject) performSelector:withObject:] ()  
8  0x3660d2f8 in -[NSArray makeObjectsPerformSelector:withObject:] ()  
9  0x36190808 in -[MKLocationManager _reportLocationStatus:] ()  
10 0x36191d72 in -[MKLocationManager _reportLocationSuccess] ()
11 0x361919cc in -[MKLocationManager locationManager:didUpdateToLocation:fromLocation:] ()  
12 0x33bfbc2c in -[CLLocationManager onClientEventLocation:] ()  
13 0x33bfbf48 in -[CLLocationManager onClientEvent:supportInfo:] ()  
14 0x33bfdd04 in OnClientEventInternal ()  
15 0x33bf57a2 in CLClientInvokeCallback ()  
16 0x33bf7c46 in CLClientHandleDaemonDataLocation ()  
17 0x33bf7d9c in CLClientHandleDaemonData ()  
18 0x3663070c in __CFMessagePortPerform ()    
19 0x36639a96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()  
20 0x3663b83e in __CFRunLoopDoSource1 ()  
21 0x3663c60c in __CFRunLoopRun ()  
22 0x365ccec2 in CFRunLoopRunSpecific ()  
23 0x365ccdca in CFRunLoopRunInMode ()  
24 0x313c141e in GSEventRunModal ()  
25 0x313c14ca in GSEventRun ()  
26 0x33390d68 in -[UIApplication _run] ()  
27 0x3338e806 in UIApplicationMain ()  
28 0x000039ca in main (argc=1, argv=0x2fdff55c) at main.m:14    
(gdb) 

更新:

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{


 MKAnnotationView* annView = nil;

    if ( [annotation isKindOfClass: [AnnotationItem class]] )
    {
        MKPinAnnotationView* pin = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier: kListingAnnotationIdentifier];

        if ( nil == pin )
        {
            pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: kListingAnnotationIdentifier] autorelease];
        }
        else
        {
            [pin setAnnotation: annotation];
        }

        pin.canShowCallout = YES;

        pin.pinColor = MKPinAnnotationColorGreen;


        UIImage* img = [UIImage imageNamed: @"logap.png"] ;
        pin.leftCalloutAccessoryView = [[[UIImageView alloc] initWithImage: img] autorelease];


        pin.rightCalloutAccessoryView = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];

        annView = pin;

    }
    return annView;



}

enabled nszombies
Is there any additional information anyone can see in this debug log that I could use to find the problem?

(gdb) bt  
0  0x30b7eca4 in objc_msgSend ()  
1  0x36179302 in -[MKMapView annotationContainer:viewForAnnotation:] ()  
2  0x36178f94 in -[MKAnnotationContainerView _addViewForAnnotation:] ()  
3  0x361a2faa in -[MKAnnotationContainerView userLocationAnnotationWillShow] ()  
4  0x3619fcbe in -[MKMapView(UserPositioningInternal) _runPositioningChange] ()  
5  0x3619da8c in -[MKMapView(UserPositioningInternal) _startPositioningChange:] ()  
6  0x361a1050 in -[MKMapView(UserPositioningInternal) locationManagerUpdatedLocation:] ()  
7  0x365cff02 in -[NSObject(NSObject) performSelector:withObject:] ()  
8  0x3660d2f8 in -[NSArray makeObjectsPerformSelector:withObject:] ()  
9  0x36190808 in -[MKLocationManager _reportLocationStatus:] ()  
10 0x36191d72 in -[MKLocationManager _reportLocationSuccess] ()
11 0x361919cc in -[MKLocationManager locationManager:didUpdateToLocation:fromLocation:] ()  
12 0x33bfbc2c in -[CLLocationManager onClientEventLocation:] ()  
13 0x33bfbf48 in -[CLLocationManager onClientEvent:supportInfo:] ()  
14 0x33bfdd04 in OnClientEventInternal ()  
15 0x33bf57a2 in CLClientInvokeCallback ()  
16 0x33bf7c46 in CLClientHandleDaemonDataLocation ()  
17 0x33bf7d9c in CLClientHandleDaemonData ()  
18 0x3663070c in __CFMessagePortPerform ()    
19 0x36639a96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()  
20 0x3663b83e in __CFRunLoopDoSource1 ()  
21 0x3663c60c in __CFRunLoopRun ()  
22 0x365ccec2 in CFRunLoopRunSpecific ()  
23 0x365ccdca in CFRunLoopRunInMode ()  
24 0x313c141e in GSEventRunModal ()  
25 0x313c14ca in GSEventRun ()  
26 0x33390d68 in -[UIApplication _run] ()  
27 0x3338e806 in UIApplicationMain ()  
28 0x000039ca in main (argc=1, argv=0x2fdff55c) at main.m:14    
(gdb) 

UPDATE:

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{


 MKAnnotationView* annView = nil;

    if ( [annotation isKindOfClass: [AnnotationItem class]] )
    {
        MKPinAnnotationView* pin = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier: kListingAnnotationIdentifier];

        if ( nil == pin )
        {
            pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: kListingAnnotationIdentifier] autorelease];
        }
        else
        {
            [pin setAnnotation: annotation];
        }

        pin.canShowCallout = YES;

        pin.pinColor = MKPinAnnotationColorGreen;


        UIImage* img = [UIImage imageNamed: @"logap.png"] ;
        pin.leftCalloutAccessoryView = [[[UIImageView alloc] initWithImage: img] autorelease];


        pin.rightCalloutAccessoryView = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];

        annView = pin;

    }
    return annView;



}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半岛未凉 2024-11-30 19:49:07

当地图视图尝试显示(更改)用户位置时,您的调试日志显示崩溃。用户位置是 MKUserLocation 类的注释,如果该注释被传递给您的 mapView:viewForAnnotation 实现,您的代码将返回一个指向 nil 的指针> (也就是说,它返回一个名为 annViewMKAnnotationView 对象,其值设置为 nil)。

因此,我怀疑当用户的位置出现或在屏幕上移动时,或者 nil 和“值设置为 MKAnnotationView 对象”之间的差异,您会崩溃。 nil”可能会在难以重现的时候突然对 Cocoa 产生重要影响。尝试测试注释是否属于 MKUserLocation 类,并在这种情况下显式返回 nil

Your debug log shows a crash when the mapView is trying to display (a change in) the user's location. User location is an annotation of class MKUserLocation, and if that annotation gets passed to your implementation of mapView:viewForAnnotation, your code returns a pointer to nil (that is, it returns an MKAnnotationView object named annView, whose value is set to nil).

So I suspect you're crashing when the user's location appears or moves on screen, or that the difference between nil and "an MKAnnotationView object whose value is set to nil" may suddenly matter to Cocoa at hard-to-reproduce times. Try testing for whether the annotation is of class MKUserLocation, and explicitly returning nil in this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文