View Full Version : Can anyone help me understand this objective-c code?

Feb 5, 2009, 01:19 PM
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.

Feb 5, 2009, 01:25 PM
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.


Feb 5, 2009, 01:50 PM
I get it now. :-)

Feb 5, 2009, 06:26 PM
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.