views:

24

answers:

1

In simple terms I have a view with three buttons;

buttonOne
buttonTwo
checkButtonStatus

if buttonOne is clicked it sets its own selected status to yes and buttonTwo selected status to no. Clicking buttonTwo does the opposite.

Both buttonOne and buttonTwo by default are not selected.

The third button (checkButtonStatus) should perform a check to make sure at least one of the other two has been clicked.

I have the code detailed below:

- (IBAction)setButtonOne:(id)sender {
    buttonOne.selected = YES;
    buttonTwo.selected = NO;
}

- (IBAction)setButtonTwo:(id)sender {
    buttonOne.selected = NO;
    buttonTwo.selected = YES;
}

- (IBAction)checkButtons:(id)sender {
    if (buttonOne.selected = NO || buttonTwo.selected = NO) {
    UIAlertView *callAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"You have not selected a button"
       delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [callAlert show];
    [callAlert release];
    }    
}

The error I'm getting is 'Lvalue required as left operand of assignment'.

I'm not a programmer, I'm a sysadmin who's been asked to prototype something and can't get it working. All help greatly appreciated.

+1  A: 

You need to use '==', not a single '=' when testing equality is your -checkButtons method.

Ben Gottlieb
You can also use `[buttonOne isSelected:NO];` instead if you wanna get rid of the equal signs
iWasRobbed
Talk about an embarrassing error. Thanks very much for the quick response. Will mark as answer in seven minutes time!
Marko Carter