5 Replies
      Latest reply on Jan 11, 2020 11:25 AM by dmyatt904
      dmyatt904 Level 1 Level 1 (0 points)

        I am redoing an old objective c- app where I previously drew the text fields out on the view. I am now using the storyboard and I cannot find a way to save the background color in a plist array. It will save the text entered just fine in the plist array. I tried using NSUserdefaults no luck. I have a golf scorecard and I am looping through the textfields and comparing the score number to the par number, thus adding a different color background to the textfield: depending on the score inputed in the textfield. I could just loop back through them again when view is loaded, but was just wanting a way to save the state in a simple plist or NSUserdefaults. Looks like I might have to just make a custom textfield class. Any suggestions? Maybe need to think the whole way of laying out the textfields. I have them tagged now to locate their position on the view. I tried saving the UIcolor under the String array but I get a nstagged error when trying to add to textfield.....

        Thanks

        • Re: Saving a uitextfield background color
          Claude31 Level 8 Level 8 (7,845 points)

          I have a golf scorecard and I am looping through the textfields and comparing the score number to the par number, thus adding a different color background to the textfield

           

          So, the color is computed for each textField ?

          Why do you need to store ?

          Why not set the color for each in viewWillAppear for instance ?

           

          I tried saving the UIcolor under the String array but I get a nstagged error when trying to add to textfield.....

          Which StringArray ?

          Could you show the code ?

           

          Storing color in User Defaults can be done:

          h ttps://medium.com/better-programming/save-uicolor-with-userdefaults-in-swift-5-951ef1aa88e8

            • Re: Saving a uitextfield background color
              dmyatt904 Level 1 Level 1 (0 points)

              I decided just to compute the background colors in the view instead of storing them. But I am bad at arrarys and loops. So there has to a better way to do the code that I am using. It worksgood but it is just a lot of code to use (I think) for getting the results I need. I am taking a string value from an nsmutable array and then appling the appropriate background color as a result of the par score I know to be on every hole. I am comparing enterable numbers from a keypad from 1 to 9 against the "par" number for up to four players. I am sure this probably could be done in a for loop with arrays. However I did not know how to make a variable for the self.nameOne1.text to the next comparison of self.nameOne2.text on so on up to self.nameFour9. Any suggestions or opinions on a more logical fix would be appreciated. The code below goes from the array [playerOneFront objectAtIndex:0] all the way to [playerFourFront objectAtIndex:8], thus covering the score for the nine holes on the front side of the golf course. The self.nameOne1 thru self.nameFour9 Then I take the score on the first hole and the give it the appropriate backgound color for the par number on that hole. example if ([frontScore isEqual:@"3"])

              {

                      self.nameOne1.backgroundColor = [UIColor systemGreenColor];

                }

              give a green backgroung for a birdie which is one number under "par" which is "4";

               

              here is all the code......

               

              -(void)getBackgrounds{

               

                  // player one

               

                      frontScore = [playerOneFront objectAtIndex:0];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne1.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne1.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:1];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne2.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:2];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne3.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameOne3.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne3.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:3];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne4.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne4.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:4];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne5.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:5];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne6.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameOne6.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne6.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:6];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne7.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne7.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:7];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne8.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne8.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerOneFront objectAtIndex:8];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameOne9.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameOne9.backgroundColor = [UIColor systemGrayColor];

                  }

                  // player Two

               

                      frontScore = [playerTwoFront objectAtIndex:0];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo1.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:1];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo2.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:2];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameTwo3.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo3.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:3];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo4.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:4];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo5.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:5];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameTwo6.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo6.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:6];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo7.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:7];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo8.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerTwoFront objectAtIndex:8];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameTwo9.backgroundColor = [UIColor systemGrayColor];

                  }

                  // player Three

               

                      frontScore = [playerThreeFront objectAtIndex:0];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree1.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree1.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:1];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree2.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:2];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree3.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameThree3.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree3.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:3];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree4.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree4.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:4];//////////////

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree5.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:5];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree6.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameThree6.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree6.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:6];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree7.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree7.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:7];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree8.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree8.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerThreeFront objectAtIndex:8];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameThree9.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameThree9.backgroundColor = [UIColor systemGrayColor];

                  }

               

              // player Four

               

                      frontScore = [playerFourFront objectAtIndex:0];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour1.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour1.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:1];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour2.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour2.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:2];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour3.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameFour3.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour3.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:3];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour4.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour4.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:4];//////////////

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour5.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour5.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:5];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour6.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"4"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"6"])

                     {

                      self.nameFour6.backgroundColor = [UIColor systemOrangeColor];

                     }

                  if ([frontScore isEqual :@"7"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour6.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:6];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour7.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour7.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:7];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour8.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour8.backgroundColor = [UIColor systemGrayColor];

                  }

                  frontScore = [playerFourFront objectAtIndex:8];

                  

                  if ([frontScore isEqual:@"1"])

                  {

                      self.nameFour9.backgroundColor = [UIColor colorWithRed:252.0/255.0

                      green:194.0/255.0 blue:0 alpha:1.0];

                  }

                  if ([frontScore isEqual:@"2"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemBlueColor];

                  }

                  if ([frontScore isEqual:@"3"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemGreenColor];

                  }

                  if ([frontScore isEqual:@"5"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemRedColor];

                  }

                  if ([frontScore isEqual:@"6"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemPurpleColor];

                  }

                  if ([frontScore isEqual:@"7"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemOrangeColor];

                  }

                  if ([frontScore isEqual:@"8"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemGrayColor];

                  }

                  if ([frontScore isEqual:@"9"])

                  {

                      self.nameFour9.backgroundColor = [UIColor systemGrayColor];

                  }

              }

                • Re: Saving a uitextfield background color
                  PBK Level 7 Level 7 (3,435 points)

                  Here you go.  Unfortunately you will need to convert to Swift if you are using that language.  It is line-for-line convertable.

                   

                  (EDIT - If you create the UITextFields programmatically then you can add them to the dictionary when they are created.  Otherwise you need to type in the 72 UITextField pointers into the dictionary.)

                   

                   

                   // colors for the sore. par is index 3...
                      NSArray *theColors=[NSArray arrayWithObjects:
                              [UIColor colorWithRed:252.0/255.0 green:194.0/255.0 blue:0 alpha:1.0],
                              [UIColor blueColor],
                              [UIColor greenColor],//birdie
                              [UIColor redColor],  //par
                              [UIColor purpleColor],
                              [UIColor orangeColor],
                              [UIColor grayColor],nil];
                  
                    // the par values for all the holes
                      NSArray *parValues=[NSArray arrayWithObjects:@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5", nil]; // 18 holes
                      
                      // a dictionary with pointers to all of the textfields
                      NSDictionary *playerTextFields=[NSDictionary dictionaryWithObjectsAndKeys:
                              @"Player1",[NSArray arrayWithObjects:nameOne1,nameOne2,nameOne3,nameOne4,nameOne5,nameOne6,nameOne7,nameOne8,nameOne9,nameOne10,nameOne11,nameOne12,nameOne13,nameOne14,nameOne15,nameOne16,nameOne17,nameOne18, nil]
                              ,@"Player2",[NSArray
                                  arrayWithObjects:nameTwo1,nameTwo2,nameTwo3,nameTwo4 // continue for all nameTwo
                              ,@"Player3"  // continue for player 3 textfields
                              .@"Player4"  //                     
                            ];
                      // typical scores for each player
                      NSDictionary *playerScores=[NSDictionary dictionaryWithObjectsAndKeys:
                    @"Player1Scores",
                    [NSArray arrayWithObjects:@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",
                    @"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5", nil],
                    @"Player2Scores",
                    [NSArray arrayWithObjects:@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",
                    @"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5", nil],
                    @"Player3Scores",
                    [NSArray arrayWithObjects:@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",
                    @"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5", nil],
                    @"Player4Scores",
                    [NSArray arrayWithObjects:@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5",@"4",
                    @"4",@"4",@"3",@"5",@"4",@"4",@"4",@"3",@"5", nil]];
                      
                      for(int hole=0;hole<=17;hole++){  //objects in the array are 0-17 not 1-18
                          int par=[[parValues objectAtIndex:hole] intValue];
                          for (int player=1; player<=4; player++) {
                              int score=[[[playerScores objectForKey:
                    [NSString stringWithFormat:@"Player%iScores",player]] 
                    objectAtIndex:hole] intValue];
                              if(score<par-3)score=par-3;
                              if(score>par+3)score=par+3;
                              UIColor *theHoleColor=[theColors objectAtIndex:(score-par+3)];
                              UITextField *thePlayersHoleTextField=[[playerTextFields objectForKey:
                     
                    • Re: Saving a uitextfield background color
                      PBK Level 7 Level 7 (3,435 points)

                      I just noticed the following lines were missing from the code above:

                       

                                thePlayersHoleTextField.backgroundColor=theHoleColor;
                           }// ends the player 1-4
                      }//ends the hole 0-17
                      
                      
                      • Re: Saving a uitextfield background color
                        dmyatt904 Level 1 Level 1 (0 points)

                        Thanks, Sorry it took so long to reply back. Had a death in the family. Have not had time to try this. But will mark correct answer as I am pretty sure it will work. The problem I have now is that I have the top 9 holes in a paginated scrollview that works great on an iphone 8, but on an iphone 8 plus the bottom of the top view (hole 9) goes to far up in the first page. I am using autolayout, but I have not figured out a good way to get the scrollview to stop at hole 9 on bottom of 1st page on both devices. Any suggestions? Thanks again.