objc2_foundation/generated/
NSTimer.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern_class!(
12 #[unsafe(super(NSObject))]
14 #[derive(Debug, PartialEq, Eq, Hash)]
15 pub struct NSTimer;
16);
17
18#[cfg(feature = "objc2-core-foundation")]
19impl AsRef<NSTimer> for CFRunLoopTimer {
20 #[inline]
21 fn as_ref(&self) -> &NSTimer {
22 unsafe { &*((self as *const Self).cast()) }
23 }
24}
25
26#[cfg(feature = "objc2-core-foundation")]
27impl AsRef<CFRunLoopTimer> for NSTimer {
28 #[inline]
29 fn as_ref(&self) -> &CFRunLoopTimer {
30 unsafe { &*((self as *const Self).cast()) }
31 }
32}
33
34extern_conformance!(
35 unsafe impl NSObjectProtocol for NSTimer {}
36);
37
38impl NSTimer {
39 extern_methods!(
40 #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
41 #[unsafe(method(timerWithTimeInterval:invocation:repeats:))]
42 #[unsafe(method_family = none)]
43 pub unsafe fn timerWithTimeInterval_invocation_repeats(
44 ti: NSTimeInterval,
45 invocation: &NSInvocation,
46 yes_or_no: bool,
47 ) -> Retained<NSTimer>;
48
49 #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
50 #[unsafe(method(scheduledTimerWithTimeInterval:invocation:repeats:))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn scheduledTimerWithTimeInterval_invocation_repeats(
53 ti: NSTimeInterval,
54 invocation: &NSInvocation,
55 yes_or_no: bool,
56 ) -> Retained<NSTimer>;
57
58 #[cfg(feature = "NSDate")]
59 #[unsafe(method(timerWithTimeInterval:target:selector:userInfo:repeats:))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn timerWithTimeInterval_target_selector_userInfo_repeats(
67 ti: NSTimeInterval,
68 a_target: &AnyObject,
69 a_selector: Sel,
70 user_info: Option<&AnyObject>,
71 yes_or_no: bool,
72 ) -> Retained<NSTimer>;
73
74 #[cfg(feature = "NSDate")]
75 #[unsafe(method(scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
83 ti: NSTimeInterval,
84 a_target: &AnyObject,
85 a_selector: Sel,
86 user_info: Option<&AnyObject>,
87 yes_or_no: bool,
88 ) -> Retained<NSTimer>;
89
90 #[cfg(all(feature = "NSDate", feature = "block2"))]
91 #[unsafe(method(timerWithTimeInterval:repeats:block:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn timerWithTimeInterval_repeats_block(
102 interval: NSTimeInterval,
103 repeats: bool,
104 block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
105 ) -> Retained<NSTimer>;
106
107 #[cfg(all(feature = "NSDate", feature = "block2"))]
108 #[unsafe(method(scheduledTimerWithTimeInterval:repeats:block:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn scheduledTimerWithTimeInterval_repeats_block(
119 interval: NSTimeInterval,
120 repeats: bool,
121 block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
122 ) -> Retained<NSTimer>;
123
124 #[cfg(all(feature = "NSDate", feature = "block2"))]
125 #[unsafe(method(initWithFireDate:interval:repeats:block:))]
135 #[unsafe(method_family = init)]
136 pub unsafe fn initWithFireDate_interval_repeats_block(
137 this: Allocated<Self>,
138 date: &NSDate,
139 interval: NSTimeInterval,
140 repeats: bool,
141 block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
142 ) -> Retained<Self>;
143
144 #[cfg(feature = "NSDate")]
145 #[unsafe(method(initWithFireDate:interval:target:selector:userInfo:repeats:))]
151 #[unsafe(method_family = init)]
152 pub unsafe fn initWithFireDate_interval_target_selector_userInfo_repeats(
153 this: Allocated<Self>,
154 date: &NSDate,
155 ti: NSTimeInterval,
156 t: &AnyObject,
157 s: Sel,
158 ui: Option<&AnyObject>,
159 rep: bool,
160 ) -> Retained<Self>;
161
162 #[unsafe(method(fire))]
163 #[unsafe(method_family = none)]
164 pub fn fire(&self);
165
166 #[cfg(feature = "NSDate")]
167 #[unsafe(method(fireDate))]
168 #[unsafe(method_family = none)]
169 pub fn fireDate(&self) -> Retained<NSDate>;
170
171 #[cfg(feature = "NSDate")]
172 #[unsafe(method(setFireDate:))]
176 #[unsafe(method_family = none)]
177 pub fn setFireDate(&self, fire_date: &NSDate);
178
179 #[cfg(feature = "NSDate")]
180 #[unsafe(method(timeInterval))]
181 #[unsafe(method_family = none)]
182 pub fn timeInterval(&self) -> NSTimeInterval;
183
184 #[cfg(feature = "NSDate")]
185 #[unsafe(method(tolerance))]
186 #[unsafe(method_family = none)]
187 pub fn tolerance(&self) -> NSTimeInterval;
188
189 #[cfg(feature = "NSDate")]
190 #[unsafe(method(setTolerance:))]
192 #[unsafe(method_family = none)]
193 pub fn setTolerance(&self, tolerance: NSTimeInterval);
194
195 #[unsafe(method(invalidate))]
196 #[unsafe(method_family = none)]
197 pub fn invalidate(&self);
198
199 #[unsafe(method(isValid))]
200 #[unsafe(method_family = none)]
201 pub fn isValid(&self) -> bool;
202
203 #[unsafe(method(userInfo))]
204 #[unsafe(method_family = none)]
205 pub fn userInfo(&self) -> Option<Retained<AnyObject>>;
206 );
207}
208
209impl NSTimer {
211 extern_methods!(
212 #[unsafe(method(init))]
213 #[unsafe(method_family = init)]
214 pub fn init(this: Allocated<Self>) -> Retained<Self>;
215
216 #[unsafe(method(new))]
217 #[unsafe(method_family = new)]
218 pub fn new() -> Retained<Self>;
219 );
220}
221
222impl DefaultRetained for NSTimer {
223 #[inline]
224 fn default_retained() -> Retained<Self> {
225 Self::new()
226 }
227}