Reputation: 11
I'm creating an Safari App Extension that communicates with native code in swift.
I'm sending a message to swift, and I want the native code to ask if user accept an action, like delete something.
I found this code:
`
func dialogOKCancel(question: String, text: String) -> Bool {
let alert = NSAlert()
var image = NSImage(named:NSImage.Name(rawValue: "b.png"))
alert.icon = image;
alert.messageText = question
alert.informativeText = text
alert.alertStyle = .informational
alert.addButton(withTitle: "Permitir")
alert.addButton(withTitle: "Negar")
return alert.runModal() == .alertFirstButtonReturn
}
` But this code only opens an alert if it is inside a view class, and I want it to open in any class that wants to ask something, is that possible? I saw many implementations that uses another libs for IOS, but I want to do this in Mac OSX, thanks!
Upvotes: 0
Views: 566