0

I have an NSSlider, and want it to control an NSNumber in an app which will be created in Xcode5. Tried the code below, which returned no errors, but the slider did not change the NSNumber's value:

float sliderValue = ([sender floatValue]);
[myQCView setValue:[NSNumber numberWithInt:sliderValue] forInputKey:@"inputNumber"];

I also tried to add the .value for the sliderValue, but this returned an error:

float sliderValue = ([sender floatValue]);
[myQCView setValue:[NSNumber numberWithInt:sliderValue.value] forInputKey:@"inputNumber"];

Any suggestions ?

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66

1 Answers1

0
float sliderValue = [sender floatValue];
[myQCView setValue:[NSNumber numberWithFloat:sliderValue.value] forInputKey:@"inputNumber"];
Igor Matyushkin
  • 778
  • 4
  • 4
  • 2
    So you are saying an `NSNumber` created using an `int` won't work, but one created using a `float` will? I doubt that. – trojanfoe Mar 18 '14 at 09:31
  • Thank you. [myQCView setValue:[NSNumber numberWithFloat:sliderValue.value] forInputKey:@"inputNumber"]; Just tried the above and got an error: 'Member reference base type 'float' is not a structure or union". This error disappears when I remove '.value' from sliderValue... but then the slider does not change the parameter value. Any suggestions on how to receive the float value without the error ? – user3432279 Mar 19 '14 at 15:32