UISlider Value Changed / [sender value]??

Discussion in 'iOS Programming' started by Darkroom, Jun 28, 2009.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    what is the proper syntax to achieve this ultra simple action... grrr... what i have below apparently is incorrect. UISlider's value changed is connected to the action.

    Code:
    - (IBAction)changeAlpha:(id)sender
           {
           [self.mainView setAlpha:[sender value]];
           }
    
    Error: incompatible type for argument 1 of 'setAlpha'

    writing either [sender intValue] or [sender floatValue] (depending on how the slider's values appear) causes a crash.

    [edit] nevermind. i figured it out. sender of UISlider can't be generic type (interesting!)... has to be

    Code:
    - (IBAction)changeAlpha:(UISlider *)sender
    
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    value is kind of an unfortunate name for UISlider to use for its value.

    You either need to typecast the sender to UISlider or typecast value to CGFloat.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada

Share This Page