2012-05-10 30 views
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; 

回答

2

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

enter image description here

enter image description here

相关问题