Objective-C IOS - int for a specific string based on the value of the slider

So, I have this slider in my view and it has a maximum of 13 and minus 1. Depending on how you move the slider, the number changes and can be displayed on a label that shows the current number on which the slider is installed,

I want to be able to change int from slider to string; therefore, if the slider move is 13, I want the label to read “A +”, 12 with “A”, 11 with “A-”, etc.

Without the need to do 13-inch instructions, because I have more than one slider, is there a way to make a method that checks the progress of the slider, then converts the number to the desired letter class?

here is my code for one of the sliders

-(IBAction)sliderChanged:(id)sender{
    UISlider *slider = (UISlider *)sender;
    int progress = (int)roundf(slider.value);
    c1Grade.text = [NSString stringWithFormat:@"%d",progress];
}
// c1Grade is the label next to the slider showing the progress
+3
source
1

, : @"A+" 13, "A" 12 ..

NSArray *gradeDescriptions = [NSArray arrayWithObjects: @"", @"F", @"D-", @"D", @"D+", @"C-", @"C", @"C+", @"B-", @"B", @"B+", @"A-", @"A", @"A+", nil];
NSString *descr = [gradeDescriptions objectAt:sliderPosition];

gradeDescriptions , ivar.

+3

All Articles