In iOS 5.1 app; Why can't I see the Exception?

2020-05-07 12:38发布

问题:

I'm trying to pass control from one TableViewController, call it 'A' to another TableViewController, call it 'B'. Even though I have 'All Exceptions' enabled, I am trapping in main, line 20: which is: retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate N.B. on the far right of line 20 is "Thread 1: breakpoint 1.3" for what it is worth.

Can anyone point me in a direction that will help me see what is causing the program to halt?

//
//  main.m
//  some function
//
//  Created by JJW on 3/23/12.
//  Copyright (c) 2012 JJW, LLC. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        //return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        int retVal = -1;
        @try 
        {
            retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
        @catch (NSException* exception) 
        {
            NSLog(@"Uncaught exception: %@", exception.description);
            NSLog(@"Stack trace: %@", [exception callStackSymbols]);
        }
        return retVal;
    }
}

回答1:

Select the breakpoints tab from the project navigator. Then press the '+' at the bottom to add a breakpoint. Choose Add Exception Breakpoint. Make sure Exception Breakpoint is checked, All Exceptions, Break on throw.

Now when you run your app, as soon as an exception is thrown, it will stop in place. This will let you see the line where you are breaking.

UPDATE You could try and get rid of the try/catch statement. I've never seen one used in the application main like that.

int main(int argc, char *argv[]) {

    @autoreleasepool {
        int retVal = UIApplicationMain(argc, argv, nil, nil);
        return retVal;
    }
}


回答2:

I spent the day recreating the entire project. The new one termites with exceptions, with explanatory messages. So I guess the old app was just totally screwed up.



标签: ios xcode4