0

I want to let an Alert View pop-up if a variable x is higher than 1000. In Xcode for iPhone Xcode is giving an Error: Expected expression in front of the "if"

Here's my code so far:

if (x>1000) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Title", nil)
                                message:NSLocalizedString(@"Message", nil)
                                delegate:nil
                                cancelButtonTitle:NSLocalizedString(@"OK", nil)
                                otherButtonTitles:nil];
    [alert show];
    [alert release];
}

1 Answers1

0

Thats the Answer to my own Question:

- (void)textFieldDidEndEditing:(UITextField *)textField {

float x = ([numberOfPeople.text floatValue]);

if (x>1000) {
    UIAlertView *objAlert = [[UIAlertView alloc] 
initWithTitle:@"Fehler" message:@"The entered Number should not be higher than 1000." 
delegate:nil 
cancelButtonTitle:nil 
otherButtonTitles:@"Close",nil];
    [objAlert show];

    textField.text=@""; // clears the text field
}

}