我在下面的行中得到一个预期的表达式错误:
for (int i = [timeArray count] - 1; i >= 0; i-) {
特别是 i-) 它把事情搞砸了,我不知道该怎么做。我正在尝试构建一个秒表应用程序。这是整个声明:
//
- (void)showTime {
int hours = 0;
int minutes = 0;
int seconds = 0;
int hundredths = 0;
NSArray *timeArray = [NSArray arrayWithObjects:self.hun.text, self.sec.text, self.min.text, self.hr.text, nil];
for (int i = [timeArray count] - 1; i >= 0; i-) {
int timeComponent = [[timeArray objectAtIndex:i] intValue];
switch (i) {
case 3:
hours = timeComponent;
break;
case 2:
minutes = timeComponent;
break;
case 1:
seconds = timeComponent;
break;
case 0:
hundredths = timeComponent;
hundredths++;
break;
default:
break;
}
}