Reputation: 680
Im getting an expected expression error in the line below that is :
for (int i = [timeArray count] - 1; i >= 0; i-) {
specifically the i-) its messing with things and I don;t know what to do. I am trying to build a stopwatch app. Here's the entire statement:
//
- (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;
}
}
Upvotes: 0
Views: 87
Reputation: 18111
i-)
is not legal syntax. The compiler expects a literal or variable after the -
.
You probably meant to write i--
or --i
. Both of these statements subtract one from i
. There is a difference between them, but they are both logically correct for your loop.
Upvotes: 1