i have a question view and will show 4 answers, only 1 are correct.
but i do not want the same button to be always the correct answer.
i will like to know how do
i dont think you need to set your button's x and y here. just set the tag of your buttons, say tag 1 - 4, generate random number 1 - 4 (possible tag of your buttons), save your buttons to NSArray and do a loop like:
NSArray *buttonsArr = [[NSArray alloc]initWithObjects:button1,button2, button3, button4, nil];
int randomInt = (arc4random() % 4) + 1;
for (int i = 0; i < [buttonsArr count]; i++) {
if ([(UIButton*)[buttonsArr objectAtIndex:i] tag] == randomInt) {
[[buttonsArr objectAtIndex:i] setTitle:@"correct" forState:UIControlStateNormal];
}else{
[[buttonsArr objectAtIndex:i] setTitle:@"wrong" forState:UIControlStateNormal];
}
}