计算器应用程序运行不正常

时间:2012-12-03 11:14:22

标签: iphone objective-c

我是关于编程iphone应用程序的精彩世界的新手,我在斯坦福大学的iTunes U中发布了一个系列,他们让你构建的第一个应用程序是计算器。现在,当我去运行计算器时,我得到了调试屏幕,在这一行@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;我已经按照教程去了一个T,所以我不明白为什么我会遇到问题而且讲师不是。

//
//  CalculatorViewController.m
//  Calculator
//
//  Created by Jweezy on 3/12/12.
//  Copyright (c) 2012 Jweezy. All rights reserved.
//

#import "CalculatorViewController.h"
#import "CalculatorBrain.h"

@interface CalculatorViewController()
@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;
@property(nonatomic, strong) CalculatorBrain *brain;
@end

@implementation CalculatorViewController

@synthesize display = _display;
@synthesize userIsInTheMiddleOfEnteringANumber = _userIsInTheMiddleOfEnteringANumber;
@synthesize brain = _brain;

- (CalculatorBrain *)brain
{
    if(!_brain) _brain= [[CalculatorBrain alloc] init];
    return _brain;
}

- (IBAction)digitPressed:(UIButton *)sender {

    NSString *digit = sender.currentTitle;
    if(self.userIsInTheMiddleOfEnteringANumber){
    self.display.text = [self.display.text stringByAppendingString:digit];
    } 
    else {
        self.display.text = digit;
        self.userIsInTheMiddleOfEnteringANumber= YES;
    }

}
- (IBAction)operationPressed:(UIButton *)sender {

    if(self.userIsInTheMiddleOfEnteringANumber)[self enterPressed];
    double result = [self.brain performOperation:sender.currentTitle];
    NSString *resultString = [NSString stringWithFormat:@"%g", result];
    self.display.text = resultString;

}
- (IBAction)enterPressed {
    [self.brain  pushOperand:[self.display.text doubleValue]];
    self.userIsInTheMiddleOfEnteringANumber = NO;
}

@end

只要单击一个数字并且显示以下内容,应用程序就会崩溃

Thread 1: breakpoint1.1 at the line @property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;

1 个答案:

答案 0 :(得分:2)

看起来像这样吗?

Image showing breakpoint

这是一个断点。消息是你得到的消息。通过单击蓝色箭头所在的位置,可以轻松创建它们,而无需注意。单击它并禁用断点,或右键单击它并删除断点。