2

I've looked through a ton of other StackOverflow posts about this error and all of them provide very reasonable solutions the problem. In other words, they generally pinpoint something in the code that isn't being auto-retained, but should be and then it subsequently causes a crash.

The problem I'm having is that the line of code that Crashlytics is telling me doesn't seem to have anything that could possibly be dealloc'd.. at least that I know of. Hopefully, you'll be able to see something I'm not seeing.

I'm not able to replicate the crash myself, but Crashlytics tells me I've had 146 of these crashes across 28 different users in the last 3 months.

My MainMenuDrawerViewController is a UITableViewController that sits in my left-side drawer (using MMDrawerController).

The crash happens in -tableView:didSelectRowAtIndexPath: on the following line:

[self updateCenterWithViewControllerIdentifiedBy:@"ReportsViewController"];

The only two objects on that line are self and a string literal, so I don't understand what could possibly be dealloc'd and causing the EXC_BAD_ACCESS.

Here is the overall method (with irrelevant code cut out):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    switch (indexPath.row) {

        // removed other case statements

        case DrawerRowReports: {
            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
                [self performSegueWithIdentifier:@"ShowReportList" sender:self];
            } else {
                [self updateCenterWithViewControllerIdentifiedBy:@"ReportsViewController"];
            }

            break;
        }

        // removed other case statements

        default:
            break;
    }

}

The -updateCenterWithViewControllerIdentifiedBy: function instantiates a View Controller from the storyboard using the given identifier, then instantiates an MMNavigationController with the first view controller as the root, then updates the mm_drawerController to put that MMNavigationController into the center position.

I'll include that method as well below, BUT the Crashlytics report doesn't say the bad access happens inside the method, it says it happens at the line above.

- (nullable id) updateCenterWithViewControllerIdentifiedBy:(nullable NSString*)storyboardIdentifier {

    return [self updateCenterWithViewControllerIdentifiedBy:storyboardIdentifier withCloseAnimation:YES];
}

- (nullable id) updateCenterWithViewControllerIdentifiedBy:(nullable NSString*)storyboardIdentifier withCloseAnimation:(BOOL)withCloseAnimation {

    return [self updatePosition:DrawerCenter withViewControllerIdentifiedBy:storyboardIdentifier withValueDictionary:nil withCloseAnimation:withCloseAnimation];
}

- (nullable id) updatePosition:(DrawerPosition)position withViewControllerIdentifiedBy:(nullable NSString*)storyboardIdentifier withValueDictionary:(nullable NSDictionary*)configDictionary withCloseAnimation:(BOOL)withCloseAnimation {

    //BaseViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:storyboardIdentifier];
    UIViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:storyboardIdentifier];
    if (configDictionary != nil) {
        for (NSString *fieldname in [configDictionary allKeys]) {
            [viewController setValue:[configDictionary objectForKey:fieldname] forKey:fieldname];
        }
    }

    UINavigationController * nav = [[MMNavigationController alloc] initWithRootViewController:viewController];

    if (position == DrawerCenter) {

        [self.mm_drawerController setCenterViewController:nav
                                       withCloseAnimation:withCloseAnimation
                                               completion:nil];

    } else if (position == DrawerRight) {

        [self.mm_drawerController setRightDrawerViewController:nav];

    } else if (position == DrawerLeft) {

        [self.mm_drawerController setLeftDrawerViewController:nav];
    } else {
        NSLog(@"unknown drawer position: %ld", (long)position);
    }

    return viewController;
}
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • Have you tried build app for release, but run and debug it on a device? – Fyodor Volchyok Jan 16 '17 at 21:53
  • Yes, many times. We have thousands of active users running the app and this is one of the most commonly used features, so it's a some kind of weird occurrence. It's not something that I can replicate. However, even though it's weird, it has happened 146 times in 3 months, so it's not just a one-off error I can ignore. :( – Kenny Wyland Jan 16 '17 at 22:27
  • Are you sure crashlytics points on exactly that string? I mean, there may be difference between line of code shown in crashlytics and your actual code base. Btw do you see those crashes in xcode organizer? – Fyodor Volchyok Jan 18 '17 at 11:18

0 Answers0