Search code examples
objective-cxcodefunctionuisliderobject-type

XCode : Slider Object type when passed into a function


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?


Solution

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

    NSControl