0

I am trying to pass a slider object into a function and change its value

void sliderLoad (NSString * sliderKey, int sliderValue, id sliderOutput, id sliderSliderOutput)
{
    NSUserDefaults * sliderSavedValue = [NSUserDefaults standardUserDefaults];
    NSString * loadString = [sliderSavedValue objectForKey:sliderKey];
    int loadInt = loadString.intValue;
    sliderValue = loadInt;
    [sliderOutput setText:loadString];
    sliderSliderOutput.value = sliderValue;
}

getting errors on the last line sliderSliderOutput.value, what is the correct object type because id is wrong?

Dayn Goodbrand
  • 611
  • 7
  • 16
  • Are you using C not Objective-C? – sunkehappy Nov 10 '12 at 09:26
  • Why are you using a C method? Please provide the code, where you call this method, so you can get a useful answer – IluTov Nov 10 '12 at 13:02
  • Im still new to Objective C, so if this is being called wrong as well maybe that is part of the issue. With the last line commented out it works fine, loads the value from the db and sets its value to the textbox (sliderOutput). what i am having trouble with is displaying this value onto the slider from within the function, it does work it i do the same line of code outside the function, but having multiple sliders, this isnt really practical. – Dayn Goodbrand Nov 10 '12 at 13:54
  • I'm just wondering what you pass as the sliderSliderOutput parameter – IluTov Nov 10 '12 at 16:11
  • a slider, haha. so its a graphic representation of the variable. this is being run in viewDidLoad, the issue is passing the slider into the function, ive tried id, UISlider and IBOutlet with no success. As i said, objective C is pretty new to me so i may be doing something stupid.. – Dayn Goodbrand Nov 11 '12 at 07:02
  • sliderLoad(@"slider1ValueKey", Slider1Vlaue, Slider1Output, Slider1SliderOutput); – Dayn Goodbrand Nov 11 '12 at 07:03
  • *sliderLoad(key for db, slider1 variable, textbox output, slider output) – Dayn Goodbrand Nov 11 '12 at 07:05

1 Answers1

0

You have to use sliderSliderOutput.doubleValue = sliderValue; For more information, take a look at the NSControl Documentation.

NSControl

IluTov
  • 6,807
  • 6
  • 41
  • 103