Hi.
I am trying to find the average time used in the quiz.
I am doing this, which always returns 0:
Code:
- (float)findAverageTime {
NSCharacterSet* nonDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
int value = 0;
for(int i=0;i<[userData count];i++) {
int currentRow = [[[[userData objectAtIndex:i] objectForKey:@"kTimeUsed"] stringByTrimmingCharactersInSet:nonDigits] intValue];
value += currentRow;
}
NSLog(@"value : %i", value);
return value/[userData count];
}
I am also trying to use this method, which returns # of passed tests, but i want to display it as percentage. How do i do that?
Code:
- (int)passedTests {
int count = 0;
for(int i=0;i<[userData count];i++) {
if ([[[userData objectAtIndex:i] objectForKey:@"kPassed"] isEqualToString:@"YES"]) {
count++;
}
}
return count;
}