Reference:
1. http://www.gamemastercn.com/archives/127
2.http://stackoverflow.com/questions/2919826/how-do-i-implement-a-message-box-in-a-cocoa-application
使用CFUserNotificationisplayAlert:
CFOptionFlags result; NSString *strMsg = [NSString stringWithFormat:@"%i", 234]; CFStringRef* msg_ref;/* CFUserNotificationDisplayAlert(0, kCFUserNotificationNoDefaultButtonFlag, NULL, NULL, NULL, CFSTR("Title"), CFSTR("Message"), NULL, NULL, NULL, &result);*/
CFStringRef theString = CFStringCreateWithFormat (kCFAllocatorDefault,NULL,CFSTR("pi = %.2f %@\n"), 3.1415,CFSTR(".")); CFShow(theString);
NSAlert *alert = [[NSAlert alloc] init]; //[alert addButtonWithTitle:@"OK"]; //[alert addButtonWithTitle:@"Cancel"]; [alert setMessageText:@"Delete the record?"]; //[alert setInformativeText:@"Deleted records cannot be restored."]; //[alert setAlertStyle:NSWarningAlertStyle]; // [alert setHelpAnchor:@"ddd"]; // [alert setInformativeText:@"asdfa"]; // [alert setMessageText:strMsg]; /* [alert beginSheetModalForWindow:_window modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; */ [alert runModal];