运行一次方法后应用程序崩溃

时间:2012-05-10 16:31:33

标签: objective-c c cocoa

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

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

第3行以绿色阴影显示,并在右侧显示“Thread 1:signal 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;

1 个答案:

答案 0 :(得分:2)

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

enter image description here

enter image description here