I’m learning Obj-C and trying to build my first apps.
I wanted to do something using UISwitch.
Sadly I have problem with checking value of this element.
I got such action:
@synthesize SwitchValue;
[...]
- (IBAction)ToggleEnabled{
if ([SwitchValue isOn]) {
NSLog(@"Switch ON");
// [myImageView startAnimating];
} else {
NSLog(@"Switch OFF");
// [myImageView stopAnimating];
}
The problem is that in logs are displayed only:
2012-02-12 13:50:56.764 App[2763:f803] Switch OFF
2012-02-12 13:50:57.965 App[2763:f803] Switch OFF
2012-02-12 13:50:58.848 App[2763:f803] Switch OFF
By each setting of toggle.
I tried conditional even with “SwitchValue.on” or “SwitchValue.enabled” but didn’t work as well.
Seems like your
IBoutlet UISwitch *SwitchValue;is not connected to xib file’s Switch. Double check this and you can do this way: