0

可能是一个愚蠢的错误,但我只需要知道为什么我的应用程序在按下按钮后会关闭。它会在一两秒钟内给出所需的答案,然后关闭。为什么?然后它带我到这个:

1{
2    @autoreleasepool {
3        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
4    }
5}

第 3 行以绿色阴影显示,右侧显示“线程 1:信号 SIGBART”。

这是代码:

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    //dismiss the keyboard
    [textField resignFirstResponder];
    return YES;

}

@synthesize go;
@synthesize start;
@synthesize calc;
@synthesize answer;
@synthesize input;
@synthesize count;

- (void)updateTipTotals
{

    int fuzzy = [input.text intValue];


    //handle divide by 0
    if (fuzzy %3 == 0 && fuzzy % 7 == 0) {
        answer.text = @"Fuzzy Ducky";
    }else {
        if (fuzzy% 7 == 0) {
            answer.text = @"Ducky";
        }
        else {
            if (fuzzy % 3 == 0) {
                answer.text = @"Fuzzy";
            }else {
                answer.text = input.text;
            }
        }
    }

}

-(IBAction)calcTouchDown:(id)sender{

    [self updateTipTotals];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    //this informs the text fields the controller is their delegate
    input.delegate = self;
    start.delegate = self;
4

1 回答 1

2

运行前尝试在 Xcode 中设置异常断点。然后它应该突出显示实际导致崩溃的代码行。

在此处输入图像描述

在此处输入图像描述

于 2012-05-10T16:35:16.430 回答