How to show alert pop-up in in Cocoa on macOS?
alert, cocoa
Solution
You can use `NSAlert` in cocoa. This is same as `UIAlertView` in ios. you can pop-up alert by this
NSAlert *alert = [NSAlert alertWithMessageText:@"Alert" defaultButton:@"Ok" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Alert pop up displayed"];
[alert runModal];
EDIT:
This is the latest used method as above method is deprecated now.
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Message text."];
[alert setInformativeText:@"Informative text."];
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"Ok"];
[alert runModal];
Problem
I want to display a pop-up for displaying information in macOS, similar to a UIAlert or UIAlertController in iOS. Is their anything in Cocoa similar to UIAlertView in iOS? How can I pop-up an alert in macOS?