I have UISwitchwith the relevant UIControlEventValueChangedassociated with the function [- handleSwitch:].
View controller
- (IBAction)handleSwitch:(UISwitch *)sender
{
static BOOL oldState;
if (sender.on && !oldState) {
NSLog(@"off => on");
} else if (oldState && !sender.on) {
NSLog(@"on => off");
} else if (oldState && sender.on) {
NSLog(@"Big bug source: on => on");
} else {
NSLog(@"Big bug source: off => off");
}
oldState = sender.on;
}
The program works fine when I press the switch once every few seconds. However, as soon as I start sending spam, I start getting a “big source of errors”.
It seems sender.onto change back to its old value before calling the function [- handleSwitch].
- Switching changes from
OfftoOn - The value changed event is queued
- Switching changes from
OntoOff [- handleSwitch:] . , Off, , On , .[- handleSwitch] . , .
:
? UISwitch ?
, . On = > On Off = > Off ?
, [- handleSwitch]? , , ?
, , , ? UISwitch , . , , , .