Xcode is telling me that I'm missing a ')' but I can't tell where it should go; it makes no sense to me. Have commented out the error message.
Xcode告诉我,我错过了')',但我不知道应该去哪里;对我来说完全是无稽之谈。已注释掉错误消息。
Can you look at the code and tell me where it's wrong?
你能看一下代码并告诉我哪里错了吗?
Thank you.
CalculatorViewController.m
#import "CalculatorViewController.h"
@interface CalculatorViewController()
@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;
@end
@implementation CalculatorViewController
@synthesize display;
@synthesize userIsInTheMiddleOfEnteringANumber;
- (IBAction)digitPressed:(UIButton *)sender
{
NSString *digit = [sender currentTitle];
self.display.text = [self.display.text stringByAppendingString:digit];
if (self userIsInTheMiddleOfEnteringANumber) { // Expected ')'
self.display.text = [self.display.text stringByAppendingString:digit];
} else {
self.display.text = digit;
self.userIsInTheMiddleOfEnteringANumber = YES;
}
}
@end
1 个解决方案
#1
7
Actually, you're missing brackets. Xcode just assumed you didn't want them since you didn't have an open bracket, so you got the error that you didn't close your parentheses.
实际上,你缺少括号。 Xcode只是假设你不想要它们,因为你没有一个开括号,所以你得到的错误是你没有关闭括号。
if([self userIsInTheMiddleOfEnteringANumber]) {
^ ^
#1
7
Actually, you're missing brackets. Xcode just assumed you didn't want them since you didn't have an open bracket, so you got the error that you didn't close your parentheses.
实际上,你缺少括号。 Xcode只是假设你不想要它们,因为你没有一个开括号,所以你得到的错误是你没有关闭括号。
if([self userIsInTheMiddleOfEnteringANumber]) {
^ ^