【问题标题】:objc_msgSend crash : how can I find where?objc_msgSend 崩溃:我怎样才能找到哪里?
【发布时间】:2011-07-13 14:04:48
【问题描述】:

启用 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;



}

【问题讨论】:

  • 你能发布 viewForAnnotation 方法的代码吗?
  • 他很难做到,MKMapView 在 Apple 的 MapKit 框架中。
  • 感谢您的关注!我用代码更新了我的问题。它很少发生,我几乎无法重现它。
  • 这有什么更新吗?我在同一个地方发生崩溃,通常是在我们的应用恢复时。

标签: iphone crash mkmapview


【解决方案1】:

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

所以我怀疑当用户的位置出现或在屏幕上移动时你会崩溃,或者nil 和“一个值设置为nilMKAnnotationView 对象”之间的差异可能突然对 Cocoa 很重要难以重现的时代。尝试测试注解是否属于MKUserLocation 类,并在这种情况下显式返回nil

【讨论】:

  • 感谢 Scott,我认为您的做法是正确的,因为它在 wifi 上崩溃的次数更少,而在实际的 iPhone 上崩溃的次数更多。这是我输入的内容。 if ([annotation isKindOfClass:[MKUserLocation class]]) { return nil; } // 我不太确定有什么区别,因为最初的实现也会返回 nil。
  • 其实我现在明白你的意思了。返回 MKAnnotationView* annView = nil; vs 返回零。好吧,我把它放进去。让我们看看它是否有所作为。会及时更新,再次感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多