objc2_foundation/generated/
NSTimer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nstimer?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSTimer;
14);
15
16unsafe impl NSObjectProtocol for NSTimer {}
17
18impl NSTimer {
19    extern_methods!(
20        #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
21        #[unsafe(method(timerWithTimeInterval:invocation:repeats:))]
22        #[unsafe(method_family = none)]
23        pub unsafe fn timerWithTimeInterval_invocation_repeats(
24            ti: NSTimeInterval,
25            invocation: &NSInvocation,
26            yes_or_no: bool,
27        ) -> Retained<NSTimer>;
28
29        #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
30        #[unsafe(method(scheduledTimerWithTimeInterval:invocation:repeats:))]
31        #[unsafe(method_family = none)]
32        pub unsafe fn scheduledTimerWithTimeInterval_invocation_repeats(
33            ti: NSTimeInterval,
34            invocation: &NSInvocation,
35            yes_or_no: bool,
36        ) -> Retained<NSTimer>;
37
38        #[cfg(feature = "NSDate")]
39        #[unsafe(method(timerWithTimeInterval:target:selector:userInfo:repeats:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn timerWithTimeInterval_target_selector_userInfo_repeats(
42            ti: NSTimeInterval,
43            a_target: &AnyObject,
44            a_selector: Sel,
45            user_info: Option<&AnyObject>,
46            yes_or_no: bool,
47        ) -> Retained<NSTimer>;
48
49        #[cfg(feature = "NSDate")]
50        #[unsafe(method(scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
53            ti: NSTimeInterval,
54            a_target: &AnyObject,
55            a_selector: Sel,
56            user_info: Option<&AnyObject>,
57            yes_or_no: bool,
58        ) -> Retained<NSTimer>;
59
60        #[cfg(all(feature = "NSDate", feature = "block2"))]
61        /// Creates and returns a new NSTimer object initialized with the specified block object. This timer needs to be scheduled on a run loop (via -[NSRunLoop addTimer:]) before it will fire.
62        /// - parameter:  timeInterval  The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead
63        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
64        /// - parameter:  block  The execution body of the timer; the timer itself is passed as the parameter to this block when executed to aid in avoiding cyclical references
65        #[unsafe(method(timerWithTimeInterval:repeats:block:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn timerWithTimeInterval_repeats_block(
68            interval: NSTimeInterval,
69            repeats: bool,
70            block: &block2::Block<dyn Fn(NonNull<NSTimer>)>,
71        ) -> Retained<NSTimer>;
72
73        #[cfg(all(feature = "NSDate", feature = "block2"))]
74        /// Creates and returns a new NSTimer object initialized with the specified block object and schedules it on the current run loop in the default mode.
75        /// - parameter:  ti    The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead
76        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
77        /// - parameter:  block  The execution body of the timer; the timer itself is passed as the parameter to this block when executed to aid in avoiding cyclical references
78        #[unsafe(method(scheduledTimerWithTimeInterval:repeats:block:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn scheduledTimerWithTimeInterval_repeats_block(
81            interval: NSTimeInterval,
82            repeats: bool,
83            block: &block2::Block<dyn Fn(NonNull<NSTimer>)>,
84        ) -> Retained<NSTimer>;
85
86        #[cfg(all(feature = "NSDate", feature = "block2"))]
87        /// Initializes a new NSTimer object using the block as the main body of execution for the timer. This timer needs to be scheduled on a run loop (via -[NSRunLoop addTimer:]) before it will fire.
88        /// - parameter:  fireDate   The time at which the timer should first fire.
89        /// - parameter:  interval  The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead
90        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
91        /// - parameter:  block  The execution body of the timer; the timer itself is passed as the parameter to this block when executed to aid in avoiding cyclical references
92        #[unsafe(method(initWithFireDate:interval:repeats:block:))]
93        #[unsafe(method_family = init)]
94        pub unsafe fn initWithFireDate_interval_repeats_block(
95            this: Allocated<Self>,
96            date: &NSDate,
97            interval: NSTimeInterval,
98            repeats: bool,
99            block: &block2::Block<dyn Fn(NonNull<NSTimer>)>,
100        ) -> Retained<Self>;
101
102        #[cfg(feature = "NSDate")]
103        #[unsafe(method(initWithFireDate:interval:target:selector:userInfo:repeats:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithFireDate_interval_target_selector_userInfo_repeats(
106            this: Allocated<Self>,
107            date: &NSDate,
108            ti: NSTimeInterval,
109            t: &AnyObject,
110            s: Sel,
111            ui: Option<&AnyObject>,
112            rep: bool,
113        ) -> Retained<Self>;
114
115        #[unsafe(method(fire))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn fire(&self);
118
119        #[cfg(feature = "NSDate")]
120        #[unsafe(method(fireDate))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn fireDate(&self) -> Retained<NSDate>;
123
124        #[cfg(feature = "NSDate")]
125        /// Setter for [`fireDate`][Self::fireDate].
126        #[unsafe(method(setFireDate:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setFireDate(&self, fire_date: &NSDate);
129
130        #[cfg(feature = "NSDate")]
131        #[unsafe(method(timeInterval))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn timeInterval(&self) -> NSTimeInterval;
134
135        #[cfg(feature = "NSDate")]
136        #[unsafe(method(tolerance))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn tolerance(&self) -> NSTimeInterval;
139
140        #[cfg(feature = "NSDate")]
141        /// Setter for [`tolerance`][Self::tolerance].
142        #[unsafe(method(setTolerance:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setTolerance(&self, tolerance: NSTimeInterval);
145
146        #[unsafe(method(invalidate))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn invalidate(&self);
149
150        #[unsafe(method(isValid))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn isValid(&self) -> bool;
153
154        #[unsafe(method(userInfo))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn userInfo(&self) -> Option<Retained<AnyObject>>;
157    );
158}
159
160/// Methods declared on superclass `NSObject`.
161impl NSTimer {
162    extern_methods!(
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167        #[unsafe(method(new))]
168        #[unsafe(method_family = new)]
169        pub unsafe fn new() -> Retained<Self>;
170    );
171}