在iOS 5.1应用中;为什么看不到异常? [英] In iOS 5.1 app; Why can't I see the Exception?

查看:40
本文介绍了在iOS 5.1应用中;为什么看不到异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从一个TableViewController传递控制,将其称为"A"到另一个TableViewController,将其称为"B".即使我启用了所有异常",我还是被困在第20行的主行中:retVal = UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegateN.B.值得的是,在第20行的最右边是线程1:断点1.3".

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;
    }
}

推荐答案

从项目导航器中选择断点"选项卡.然后按底部的"+"添加一个断点.选择添加例外断点.确保选中异常断点",所有异常",抛出异常".

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.

更新您可以尝试摆脱try/catch语句.我从未见过像这样在应用程序主体中使用过的软件.

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;
    }
}

这篇关于在iOS 5.1应用中;为什么看不到异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆