How can I make my following code "DRY" (Dont Repeat Yourself)
- (void)updateLetterScore { // NOT DRY... Must fix
if (percentScore < 60.0)
letterLabel.text = [NSString stringWithFormat:@"F"];
if (percentScore > 59.0 && percentScore < 64.0)
letterLabel.text = [NSString stringWithFormat:@"D-"];
if (percentScore > 64.0 && percentScore < 67.0)
letterLabel.text = [NSString stringWithFormat:@"D"];
if (percentScore > 66.0 && percentScore < 70.0)
letterLabel.text = [NSString stringWithFormat:@"D+"];
if (percentScore > 69.0 && percentScore < 74.0)
letterLabel.text = [NSString stringWithFormat:@"C-"];
if (percentScore > 73.0 && percentScore < 76.0)
letterLabel.text = [NSString stringWithFormat:@"C"];
if (percentScore > 76.0 && percentScore < 80.0)
letterLabel.text = [NSString stringWithFormat:@"C+"];
if (percentScore > 79.0 && percentScore < 84.0)
letterLabel.text = [NSString stringWithFormat:@"B-"];
if (percentScore > 83.0 && percentScore < 86.0)
letterLabel.text = [NSString stringWithFormat:@"B"];
if (percentScore > 85.0 && percentScore < 90.0)
letterLabel.text = [NSString stringWithFormat:@"B+"];
if (percentScore > 89.0 && percentScore < 94.0)
letterLabel.text = [NSString stringWithFormat:@"A-"];
if (percentScore > 93.0 && percentScore < 100.0)
letterLabel.text = [NSString stringWithFormat:@"A"];
if (percentScore == 100)
letterLabel.text = [NSString stringWithFormat:@"A+"];
}
Thanks for the tips. I just wanna know what you guys think because this little snippit looks HORRENDOUS in my code.