我是编程新手。我很难找出这一切有什么问题。这是一个警报视图,我试图随机化消息中显示的文本。
-(void)alert:(id)sender{
int randomNumber;
randomNumber = (randomNumber() %3 + 1);
NSLog(@"%i", randomNumber);
if (randomNumber == 1) {
self.YouWin.text = [NSString stringWithFormat:@"You Win"];
}
else if (randomNumber == 2) {
self.YouWin.text = [NSString stringWithFormat:@"You Lose"];
}
else if (randomNumber == 3) {
self.YouWin.text = [NSString stringWithFormat:@"Tie"];
}
NSLog(@"%@",YouWin);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Hello" message:[NSString stringWithFormat:@"%@",YouWin] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
button.hidden = YES;