Alert Windows
Originally published on my old QuintusQuill Console blog in April 2008.
C Method
NSRunAlertPanel(@"App Controller", @"Hello World!", @"OK", @"Cancel", NULL);Objective-C Method
NSAlert * alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];[alert addButtonWithTitle:@"Cancel"];[alert setMessageText:@"Message Text"];[alert setInformativeText:@"Informative Text"];[alert setAlertStyle:NSInformationalAlertStyle];
[alert release];Here is the code to do something when the "OK" button is pressed (make sure you insert it before you release the alert object):
if ([alert runModal] == NSAlertFirstButtonReturn){ // OK clicked, do something here}