iOS, GMSMapView, MapView: сбой приложения didTapMarker - PullRequest
2 голосов
/ 02 июля 2019

мое приложение падает, когда пользователь нажимает на маркер (GMSMapVIew: didTapMarker), и myApp работает хорошо в 99% случаев, но иногда он показывает сбой при сбое. И это произошло так случайно.

Отчет о сбое показывает следующее.

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000002f6ce97f4

-[BadgerMapView mapView:didTapMarker:]

Crashed: com.apple.main-thread

0  libobjc.A.dylib                0x1f025653c objc_msgSend + 28
1  Badger                         0x104d3af84 -[BadgerMapView mapView:didTapMarker:] + 1784 (BadgerMapView.m:1784)
2  CoreFoundation                 0x1f106b900 __invoking___ + 144
3  CoreFoundation                 0x1f0f4d4d0 -[NSInvocation invoke] + 292
4  CoreFoundation                 0x1f0f4e104 -[NSInvocation invokeWithTarget:] + 60
5  Badger                         0x104e940e0 -[GMSDelegateForward forwardInvocation:] + 4339744992
6  CoreFoundation                 0x1f10697c0 ___forwarding___ + 636
7  CoreFoundation                 0x1f106b75c _CF_forwarding_prep_0 + 92
8  Badger                         0x104ea01fc -[GMSMapView didTapMarker:] + 20436
9  Badger                         0x104eb8a88 -[GMSMarker wasTapped] + 120928
10 UIKitCore                      0x21d1c3868 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 64
11 UIKitCore                      0x21d1cba70 _UIGestureRecognizerSendTargetActions + 124
12 UIKitCore                      0x21d1c9414 _UIGestureRecognizerSendActions + 316
13 UIKitCore                      0x21d1c8940 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 760
14 UIKitCore                      0x21d1bca1c _UIGestureEnvironmentUpdate + 2180
15 CoreFoundation                 0x1f0ff55f8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
16 CoreFoundation                 0x1f0ff0320 __CFRunLoopDoObservers + 412
17 CoreFoundation                 0x1f0ff089c __CFRunLoopRun + 1228
18 CoreFoundation                 0x1f0ff00b0 CFRunLoopRunSpecific + 436
19 GraphicsServices               0x1f31f079c GSEventRunModal + 104
20 UIKitCore                      0x21d59a978 UIApplicationMain + 212
21 Badger                         0x104cb863c main + 17 (main.m:17)
22 libdyld.dylib                  0x1f0ab58e0 start + 4

Ниже мой код, где приложение сбой .

BadgerMapView.m: 1784

if (! [Waypt isKindOfClass: [NSNull class]]) This is the line where i got crash

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
  CLLocationCoordinate2D markerLocation = marker.position;
  double tappedMarkerLattitude = markerLocation.latitude;
  double tappedMarkerLongitude = markerLocation.longitude;
  NSArray *waypoints =[MapViewController sharedInstance].wayPointsToShowOnRouteMode;

  for (PlannerWaypoint *waypt in waypoints)
  {
    @try {
        if (![waypt isKindOfClass:[NSNull class]]) { 
            if (![waypt isEqual:nil]) {

                [MapViewController sharedInstance].currentWaypoint = waypt;

                NSNumber *nextWayPointIndex = [MapViewController sharedInstance].currentWaypoint.modPosition;
                NSNumber *prevWayPointIndex = [MapViewController sharedInstance].currentWaypoint.modPosition;

                int value = [nextWayPointIndex intValue];
                nextWayPointIndex = [NSNumber numberWithInt:value + 1];
                NSUInteger nextWayPointIndexInt = [nextWayPointIndex integerValue];
                prevWayPointIndex = [NSNumber numberWithInt:value - 1];
                NSUInteger prevWayPointIndexInt = [prevWayPointIndex integerValue];

                int waypointCount = (int)[waypoints count];

                if (nextWayPointIndexInt > (waypointCount-1)) {
                    [MapViewController sharedInstance].nextWaypoint = [waypoints objectAtIndex:0];
                }
                else {
                    [MapViewController sharedInstance].nextWaypoint = [waypoints objectAtIndex:nextWayPointIndexInt];
                }

                if (prevWayPointIndexInt > (waypointCount-1)) {
                    [MapViewController sharedInstance].previousWaypoint = [waypoints objectAtIndex:(waypointCount-1)];
                }
                else {
                    [MapViewController sharedInstance].previousWaypoint = [waypoints objectAtIndex:prevWayPointIndexInt];
                }

                if([Utility isIphone] == NO) {
                    [[MapViewController sharedInstance] showMarkerSelectedAtMiddle:[MapViewController sharedInstance].currentWaypoint];
                    UIViewController *viewcontroller = [MenuViewController sharedInstance].presentedViewController;
                    if([viewcontroller.childViewControllers objectAtIndex:0]!=nil) {
                        RouteModeViewController *routeModeView = [viewcontroller.childViewControllers objectAtIndex:0];
                        [routeModeView.customerCardNameLabel setText:[MapViewController sharedInstance].waypointLabel];
                    }
                } else {
                    UINavigationController *UINavController = (UINavigationController *)self.window.rootViewController.presentedViewController;
                    UIViewController *UIViewCon = [[UINavController viewControllers] lastObject];
                    if ([UIViewCon isKindOfClass:[MapViewController class]]) {
                        MapViewController *mapViewController = (MapViewController *)UIViewCon;
                        [mapViewController showMarkerSelectedAtMiddle:waypt];
                    }
                }
                [waypt release];
                waypt = nil;
                break;


            }
        }
    } @catch (NSException *exception) {
        NSLog(@"Exception in ProcessdidTapMarker: %@",exception);
        [DeviceLoger log:[NSString stringWithFormat:@"Exception in ProcessdidTapMarker: %@",exception]];
    }
 }
   return YES;
}

У кого-нибудь есть идея?

Пожалуйста, помогите мне, потому что я очень долго сталкиваюсь с этой проблемой

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...