How do I set a switch to turn off a switch?

127 Views Asked by At

I am trying to set a switch to turn off another switch when it is on. I know you use a if statement to do this, but I find it to be very different than an HTML if statement. I know my code is not right but it will explain what I need.

- (IBAction)dashieScheme:(id)sender {

    if(dashieScheme.state = true) {
       (twilightScheme.state = false);

    }
}


- (IBAction)twilightScheme:(id)sender {

    if(twilightScheme:(id)sender ) {
       (dashieScheme.state = false);

    }
}
1

There are 1 best solutions below

7
On

You want to use the following:

[dashieScheme setOn:NO animated:YES];

Also, your if statement needs some work. You want to use == to check for equality. a single = sign is for assignment.