Xcode macOS编程中的弹出消息

Xcode macOS编程中的弹出消息,xcode,macos,popup,Xcode,Macos,Popup,比如在iOS上使用UIAlertView。在macOS上创建弹出消息应该有类似的解决方案。试图搜索,但找不到任何有用的内容。您要查找的类是NSAlert。有关此类的信息,请参见其。下面是其用法的一个示例: NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Some awesome message text"]; [alert addButtonWithTitle:@"OK"]; [alert runModal];

比如在iOS上使用UIAlertView。在macOS上创建弹出消息应该有类似的解决方案。试图搜索,但找不到任何有用的内容。

您要查找的类是
NSAlert
。有关此类的信息,请参见其。下面是其用法的一个示例:

NSAlert *alert = [[NSAlert alloc] init];

[alert setMessageText:@"Some awesome message text"];
[alert addButtonWithTitle:@"OK"];
[alert runModal];
如果您的应用程序正在使用ARC(自动引用计数),则无需调用autorelease。ARC模式现在是大多数iOS和Mac OSX应用程序的标准模式。