use objc::runtime::Object;
use objc::{class, msg_send, sel, sel_impl};
use objc_id::Id;
use crate::foundation::{id, NSString};
#[derive(Debug)]
pub struct Alert(Id<Object>);
impl Alert {
pub fn new(title: &str, message: &str) -> Self {
let title = NSString::new(title);
let message = NSString::new(message);
let ok = NSString::new("OK");
Alert(unsafe {
let alert: id = msg_send![class!(NSAlert), new];
let _: () = msg_send![alert, setMessageText: title];
let _: () = msg_send![alert, setInformativeText: message];
let _: () = msg_send![alert, addButtonWithTitle: ok];
Id::from_ptr(alert)
})
}
pub fn show(&self) {
unsafe {
let _: () = msg_send![&*self.0, runModal];
}
}
}