Недавно я обновил свой Mac до Catalina и увидел странные проблемы с NSAlert ().
Когда открывается любое предупреждение, я получаю нижеуказанную ошибку в консоли, и предупреждение автоматически закрывается без нажатия пользователем кнопки ОК.
Ошибка в консоли:
this class is not key value coding-compliant for the key modalWindow.' with user dictionary {
NSTargetObjectUserInfoKey = "<ProjectName.AppDelegate: 0x100b07400>";
NSUnknownUserInfoKey = modalWindow;
}
Ниже приведен мой код для отображения оповещений.
let myPopup: NSAlert = NSAlert()
myPopup.messageText = messageText
myPopup.informativeText = infoText
myPopup.alertStyle = NSAlert.Style.warning
myPopup.addButton(withTitle: NSLocalizedString("OK", comment: "Button Text"))
let res = myPopup.runModal()
Справка: это приложение Mac, использующее swift, Xcode11 (пробовал с Xcode 11.1 и 11.2)