use objc::{msg_send, sel, sel_impl};
use rust_macios_objective_c_runtime_proc_macros::interface_impl;
use crate::{
foundation::{NSDate, NSTimeInterval},
object,
objective_c_runtime::traits::FromId,
utils::to_optional,
};
use super::IUNNotificationTrigger;
object! {
unsafe pub struct UNTimeIntervalNotificationTrigger;
}
impl IUNNotificationTrigger for UNTimeIntervalNotificationTrigger {}
#[interface_impl(UNNotificationTrigger)]
impl UNTimeIntervalNotificationTrigger {
#[method]
pub fn trigger_with_time_interval_repeats(time_interval: NSTimeInterval, repeats: bool) -> Self
where
Self: Sized + FromId,
{
unsafe {
Self::from_id(msg_send![
Self::m_class(),
triggerWithTimeInterval: time_interval
repeats: repeats
])
}
}
#[method]
pub fn next_trigger_date(&self) -> Option<NSDate> {
unsafe { to_optional(msg_send![self.m_self(), nextTriggerDate]) }
}
#[property]
pub fn time_interval(&self) -> NSTimeInterval {
unsafe { msg_send![self.m_self(), timeInterval] }
}
}