Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HarryWorksInc

macrumors regular
Original poster
Feb 21, 2010
179
0
I have a game in which the players will go one after the other and then the view will quit and go to a different view, currently i have coded as so
HTML:
	int winner1;
	int winner2;
	int winner1S;
	int winner2S;
	int winner;
	
	if (Player1Score < Player2Score) {
		winner1=1;
		winner1S=Player1Score;
	} else {
		winner1=2;
		winner1S=Player2Score;
	}
	if (Player3Score < Player4Score) {
		winner2=3;
		winner2S=Player3Score;
	} else {
		winner2=4;
		winner2S=Player4Score;
	}
	if (winner2S < winner1S) {
		winner=winner2;
	} else {
		winner=winner1;
	}
	
	NSString *winnerstring = [[NSString alloc] initWithFormat:@"%d", winner];
	[[NSUserDefaults standardUserDefaults] setObject:winnerstring forKey:@"CCW"];
	[self.delegate CreatureCaptureDidFinish:self];

This doesn't seem to be working. If anyone knows of a way I can simply organize the scores into highest to lowest I would be very grateful.
 
Create an object class that represents each player and holds, at least, their index and score. Create instances of this class for each player. Store them in an array. Sort the array using one of NSArray's sorting instance methods.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.