Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-21-2010, 05:54 AM   #1 (permalink)
Registered Member
 
cordoprod's Avatar
 
Join Date: Aug 2009
Location: Norway
Age: 17
Posts: 111
Default Finding average time used in quiz

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;
}
__________________
 MacBook Pro 15,4" 2,4GHz 4GB 250GB.
 Mac Mini 2,53GHz 4GB 320GB.
 iPhone 3GS Black 32GB.
cordoprod is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:15 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0