mercredi 30 septembre 2015

How to check if a checkbox is checked or not

I have 2 checkboxes and in my controller i want to be able to know if those checkboxes are checked or not. My code :

in .h :

@property (weak, nonatomic) IBOutlet Checkbox *option1Button;
@property (weak, nonatomic) IBOutlet Checkbox *option2Button;

in controller.m:

- (IBAction)optionButton1Pressed:(id)sender {
   NSLog(@"first : %lu second : %lu", (unsigned long)[_option1Button state], (unsigned long)[_option2Button state]);
}

- (IBAction)optionButton2Pressed:(id)sender {
   NSLog(@"first : %lu second : %lu", (unsigned long)[_option1Button state], (unsigned long)[_option2Button state]);
}

The action mapped is "touch up inside". And what i can see in the logs is that state is always 1 if i check or uncheck the checkboxes. Everytime that i click, it's a 1

I've tried with "editing changed" but it's never called

Any idea?




Aucun commentaire:

Enregistrer un commentaire