UISwitch has property 'on' defined like this:
@property(nonatomic,getter=isOn) BOOL on;
So I always thought it means '-isOn' is getter and setter is just '-on', but now I discovered I can use '-on' as both setter and getter. So in this case we can have any of these expressions:
... but this fails to compile:
Anyone care to explain why second option works as getter and why last option doesn't.
@property(nonatomic,getter=isOn) BOOL on;
So I always thought it means '-isOn' is getter and setter is just '-on', but now I discovered I can use '-on' as both setter and getter. So in this case we can have any of these expressions:
Code:
BOOL setting = theSwitch.isOn;
BOOL setting = theSwitch.on;
BOOL setting = [theSwitch isOn];
... but this fails to compile:
Code:
BOOL setting = [theSwitch on];
Anyone care to explain why second option works as getter and why last option doesn't.