I am trying to code a NSAlert, that appears when when some NSTextFields are empty. I have 3 NSTextFields and I would like to have a NSAlert that shows which TextField ist empty in a list. It´s possible for me to do it for one text field, but how can I code it that the empty NSTextFields appear in the Alert ? If one Textfield is empty in the Altert should stand "TextField 1 is empty". If Field 1 and 2 are empty there should stand "TextField 1 is empty" and in the second row "TextField 2 is empty".
Here is my code:
if ([[TextField1 stringValue] length] == 0) {
NSAlert* alert = [[NSAlert alloc]init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Error"];
[alert setInformativeText:@"TextField 1 is empty"];
[alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSInteger result) {NSLog(@"Success");}];
Best regards, Robby
Aucun commentaire:
Enregistrer un commentaire