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
16extern_conformance!(
17    unsafe impl NSObjectProtocol for NSTimer {}
18);
19
20impl NSTimer {
21    extern_methods!(
22        #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
23        #[unsafe(method(timerWithTimeInterval:invocation:repeats:))]
24        #[unsafe(method_family = none)]
25        pub unsafe fn timerWithTimeInterval_invocation_repeats(
26            ti: NSTimeInterval,
27            invocation: &NSInvocation,
28            yes_or_no: bool,
29        ) -> Retained<NSTimer>;
30
31        #[cfg(all(feature = "NSDate", feature = "NSInvocation"))]
32        #[unsafe(method(scheduledTimerWithTimeInterval:invocation:repeats:))]
33        #[unsafe(method_family = none)]
34        pub unsafe fn scheduledTimerWithTimeInterval_invocation_repeats(
35            ti: NSTimeInterval,
36            invocation: &NSInvocation,
37            yes_or_no: bool,
38        ) -> Retained<NSTimer>;
39
40        #[cfg(feature = "NSDate")]
41        #[unsafe(method(timerWithTimeInterval:target:selector:userInfo:repeats:))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn timerWithTimeInterval_target_selector_userInfo_repeats(
44            ti: NSTimeInterval,
45            a_target: &AnyObject,
46            a_selector: Sel,
47            user_info: Option<&AnyObject>,
48            yes_or_no: bool,
49        ) -> Retained<NSTimer>;
50
51        #[cfg(feature = "NSDate")]
52        #[unsafe(method(scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
55            ti: NSTimeInterval,
56            a_target: &AnyObject,
57            a_selector: Sel,
58            user_info: Option<&AnyObject>,
59            yes_or_no: bool,
60        ) -> Retained<NSTimer>;
61
62        #[cfg(all(feature = "NSDate", feature = "block2"))]
63        /// 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.
64        /// - 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
65        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
66        /// - 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
67        #[unsafe(method(timerWithTimeInterval:repeats:block:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn timerWithTimeInterval_repeats_block(
70            interval: NSTimeInterval,
71            repeats: bool,
72            block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
73        ) -> Retained<NSTimer>;
74
75        #[cfg(all(feature = "NSDate", feature = "block2"))]
76        /// 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.
77        /// - 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
78        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
79        /// - 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
80        #[unsafe(method(scheduledTimerWithTimeInterval:repeats:block:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn scheduledTimerWithTimeInterval_repeats_block(
83            interval: NSTimeInterval,
84            repeats: bool,
85            block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
86        ) -> Retained<NSTimer>;
87
88        #[cfg(all(feature = "NSDate", feature = "block2"))]
89        /// 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.
90        /// - parameter:  fireDate   The time at which the timer should first fire.
91        /// - 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
92        /// - parameter:  repeats  If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
93        /// - 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
94        #[unsafe(method(initWithFireDate:interval:repeats:block:))]
95        #[unsafe(method_family = init)]
96        pub unsafe fn initWithFireDate_interval_repeats_block(
97            this: Allocated<Self>,
98            date: &NSDate,
99            interval: NSTimeInterval,
100            repeats: bool,
101            block: &block2::DynBlock<dyn Fn(NonNull<NSTimer>)>,
102        ) -> Retained<Self>;
103
104        #[cfg(feature = "NSDate")]
105        #[unsafe(method(initWithFireDate:interval:target:selector:userInfo:repeats:))]
106        #[unsafe(method_family = init)]
107        pub unsafe fn initWithFireDate_interval_target_selector_userInfo_repeats(
108            this: Allocated<Self>,
109            date: &NSDate,
110            ti: NSTimeInterval,
111            t: &AnyObject,
112            s: Sel,
113            ui: Option<&AnyObject>,
114            rep: bool,
115        ) -> Retained<Self>;
116
117        #[unsafe(method(fire))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn fire(&self);
120
121        #[cfg(feature = "NSDate")]
122        #[unsafe(method(fireDate))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn fireDate(&self) -> Retained<NSDate>;
125
126        #[cfg(feature = "NSDate")]
127        /// Setter for [`fireDate`][Self::fireDate].
128        #[unsafe(method(setFireDate:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setFireDate(&self, fire_date: &NSDate);
131
132        #[cfg(feature = "NSDate")]
133        #[unsafe(method(timeInterval))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn timeInterval(&self) -> NSTimeInterval;
136
137        #[cfg(feature = "NSDate")]
138        #[unsafe(method(tolerance))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn tolerance(&self) -> NSTimeInterval;
141
142        #[cfg(feature = "NSDate")]
143        /// Setter for [`tolerance`][Self::tolerance].
144        #[unsafe(method(setTolerance:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn setTolerance(&self, tolerance: NSTimeInterval);
147
148        #[unsafe(method(invalidate))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn invalidate(&self);
151
152        #[unsafe(method(isValid))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn isValid(&self) -> bool;
155
156        #[unsafe(method(userInfo))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn userInfo(&self) -> Option<Retained<AnyObject>>;
159    );
160}
161
162/// Methods declared on superclass `NSObject`.
163impl NSTimer {
164    extern_methods!(
165        #[unsafe(method(init))]
166        #[unsafe(method_family = init)]
167        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
168
169        #[unsafe(method(new))]
170        #[unsafe(method_family = new)]
171        pub unsafe fn new() -> Retained<Self>;
172    );
173}