ios - how to update my label subviews based on how many player are left in the game -


quick question,

i'm new programming , have ran problem. im making game , @ end of every round winner highest score during round out, hide playerview , label of player need figure out how make method in switch case 4(self.players) label , playerview hidden isn't set , turn variable rearrange accordingly label took out of switch.

switch (self.players) {     case 5:         switch (self.turn) {             case 1:                 explanationlabel.text = [nsstring stringwithformat:@"%d",score];                 break;             case 2:                 explanationlabeltwo.text = [nsstring stringwithformat:@"%d",score];                 break;             case 3:                 explanationlabelthree.text = [nsstring stringwithformat:@"%d",score];                 break;             case 4:                 explanationlabelfour.text = [nsstring stringwithformat:@"%d",score];                 break;             case 5:                 explanationlabelfive.text = [nsstring stringwithformat:@"%d",score];                 break; 

for example if playerfour represented explanationlabelfour won first round switch 4 players should be..

 switch (self.players) { case 4:     switch (self.turn) {         case 1:             explanationlabel.text = [nsstring stringwithformat:@"%d",score];             break;         case 2:             explanationlabeltwo.text = [nsstring stringwithformat:@"%d",score];             break;         case 3:             explanationlabelthree.text = [nsstring stringwithformat:@"%d",score];             break;         case 4:             explanationlabelfive.text = [nsstring stringwithformat:@"%d",score];             break; 

the way have found make work if statements to see if each label hidden set them accordingly, super inefficient. it's dice game , after 3 rolls turn goes one.

thanks in advance!

give each of explanationlabel tag, respect self.turn

for example,

explanationlabel.tag = 1; explanationlabeltwo.tag = 2; explanationlabelthree.tag = 3; . . explanationlabeln.tag = n; 

now, you've call method named like, hidelabels

- (void) hidelabels {     explanationlabel.hidden = yes;     explanationlabeltwo.hidden = yes;     explanationlabelthree.hidden = yes; } 

you've call hidelabels before outer switch case call,

then inside cases, label object using tag

switch (self.players) {     case 5:         uilabel *tempexplanationlabel = (uilabel *)[self.view viewwithtag:self.turn];         tempexplanationlabel.hidden = no; } 

upto this, you'll show label current turn is, if want can change frame particular label better result visibility. can assining explanationlabel.frame tempexplanationlabel.frame.