Can anyone help me understand this objective-c code?

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

  1. Glama macrumors member

    Feb 5, 2009
    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. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    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.

  3. Glama thread starter macrumors member

    Feb 5, 2009
  4. ray648 macrumors regular

    Jan 10, 2008
    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