Can anyone point me in the right direction regarding sliders, the version below was my first attempt (the range is 0.0 - 100.0) The results I get are not right.
// Version 1.0
-(IBAction)sliderMoved:(id)sender {
NSLog(@"SliderValue ... %d",(int)[sender value]);
}
// OUTPUT:
// [1845:207] SliderMoved ... -1.991753
// [1845:207] SliderMoved ... 0.000000
// [1845:207] SliderMoved ... 0.000000
// [1845:207] SliderMoved ... 32768.000435
With the version below I get the values I expect, what am I missing in version_001?
// Version 2.0
-(IBAction)sliderMoved:(UISlider *)sender {
NSLog(@"SliderValue ... %d",(int)[sender value]);
}
// OUTPUT:
// [1914:207] SliderMoved ... 1
// [1914:207] SliderMoved ... 2
// [1914:207] SliderMoved ... 3
// [1914:207] SliderMoved ... 4
EDIT_001:
Adding UISlider *slider = (UISlider *)sender;
as Substance G points out does indeed work. I understand that using sender is the convention, but it seems to me in this case that not only is the convention less clear its also more complicated and more code. It would seem sensible IMO to statically type the method to (UISlider *)
as in version 2.0. Is there a situation I am overlooking in the slider IBAction method where using (UISlider *) would not work?
cheers Gary