i need to get the current value of a UISlider and put it into a variable.
my UISlider name is searchRadiusSlider and i want that the value will be %.0f.
i could display it as a String like that :
[NSString stringWithFormat:@"%.0f", [(UISlider *)sender value]];
but for my case, i want simply to get it as numeric :
self.searchRadius= //what to put here
Thx in advance 🙂
If you want to drop the decimals just cast to int and this will truncate the decimals.
If you want to round the decimals like
%.0fuse round() from math.h (Not exactly,%.0fuses banker’s rounding whereas round() uses half up rounding so 2.5 is rounded to 2 in the former and 3 in the later)