Can anyone help me understand this objective-c code?

Discussion in 'Mac Programming' started by Glama, Feb 5, 2009.

  1. macrumors member

    Joined:
    Feb 5, 2009
    #1
    UISwitch *whichSwitch = (UISwitch *) sender;
    BOOL setting = whichSwitch.isOn;
    [leftswitch setOn:setting animated:YES];
    [rightswitch SetOn:setting animating:YES];

    The last two lines especially leave me clueless.
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    It looks like whatever class leftswitch and rightswitch belong to has a method called setOn:animating: that takes two BOOL values. In this case it's passing the value of setting, which will be YES or NO for setOn, and YES for animating.

    -Lee
     
  3. thread starter macrumors member

    Joined:
    Feb 5, 2009
    #3
    Thanks Lee!

    I get it now. :)
     
  4. macrumors regular

    Joined:
    Jan 10, 2008
    #4
    Objective C is case sensitive so setOn and SetOn are different. In this code it looks like its probably a typo, but watch out for this.
     

Share This Page