rust_macios/background_tasks/
bg_task_scheduler.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    object,
5    objective_c_runtime::{
6        macros::interface_impl,
7        traits::{FromId, PNSObject},
8    },
9};
10
11object! {
12    /// A class for scheduling task requests that launch your app in the background.
13    unsafe pub struct BGTaskScheduler;
14}
15
16#[interface_impl(NSObject)]
17impl BGTaskScheduler {
18    /* Getting the Shared Task Scheduler
19     */
20
21    /// The shared background task scheduler instance.
22    #[property]
23    pub fn shared_scheduler() -> Self
24    where
25        Self: Sized + 'static + FromId,
26    {
27        unsafe { Self::from_id(msg_send![Self::m_class(), sharedScheduler]) }
28    }
29}
30
31impl Default for BGTaskScheduler {
32    fn default() -> Self {
33        Self::m_new()
34    }
35}