2012-05-10 55 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

相關問題