rust_macios/background_tasks/
bg_task.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{object,
4 foundation::NSString,
5 objective_c_runtime::{
6 macros::{interface_impl},
7 traits::{FromId, PNSObject},
8 },
9};
10
11object! {
12 unsafe pub struct BGTask;
14}
15
16#[interface_impl(NSObject)]
17impl BGTask {
18 #[property]
20 pub fn identifier(&self) -> NSString {
21 unsafe { NSString::from_id(msg_send![self.m_self(), identifier]) }
22 }
23
24 #[property]
26 pub fn expiration_handler(&self) {
27 unsafe { msg_send![self.m_self(), expirationHandler] }
28 }
29
30 #[method]
36 pub fn set_task_completed_with_success(&mut self, success: bool) {
37 unsafe { msg_send![self.m_self(), setTaskCompletedWithSuccess: success] }
38 }
39}
40
41impl Default for BGTask {
42 fn default() -> Self {
43 Self::m_new()
44 }
45}