objc2_game_kit/generated/
GKChallengeDefinition.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#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengedefinition?language=objc)
15    #[unsafe(super(NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct GKChallengeDefinition;
18);
19
20unsafe impl Send for GKChallengeDefinition {}
21
22unsafe impl Sync for GKChallengeDefinition {}
23
24extern_conformance!(
25    unsafe impl NSObjectProtocol for GKChallengeDefinition {}
26);
27
28impl GKChallengeDefinition {
29    extern_methods!(
30        /// The developer defined identifier for a given challenge definition.
31        ///
32        /// This property is not atomic.
33        ///
34        /// # Safety
35        ///
36        /// This might not be thread-safe.
37        #[unsafe(method(identifier))]
38        #[unsafe(method_family = none)]
39        pub unsafe fn identifier(&self) -> Retained<NSString>;
40
41        /// The group identifier for the challenge definition, if one exists.
42        ///
43        /// This property is not atomic.
44        ///
45        /// # Safety
46        ///
47        /// This might not be thread-safe.
48        #[unsafe(method(groupIdentifier))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn groupIdentifier(&self) -> Option<Retained<NSString>>;
51
52        /// A short title for the challenge definition.
53        ///
54        /// This property is not atomic.
55        ///
56        /// # Safety
57        ///
58        /// This might not be thread-safe.
59        #[unsafe(method(title))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn title(&self) -> Retained<NSString>;
62
63        /// A more detailed description of the challenge definition.
64        ///
65        /// This property is not atomic.
66        ///
67        /// # Safety
68        ///
69        /// This might not be thread-safe.
70        #[unsafe(method(details))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn details(&self) -> Option<Retained<NSString>>;
73
74        /// The duration options for the challenge, like `1 day` or `1 week`.
75        /// - Note: If set, the amount of weeks is stored in the `weekOfYear` field.
76        /// - Important: The actual duration of the challenge may be dynamically adjusted
77        /// in order to accommodate different factors like players' timezones.
78        ///
79        /// This property is not atomic.
80        ///
81        /// # Safety
82        ///
83        /// This might not be thread-safe.
84        #[unsafe(method(durationOptions))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn durationOptions(&self) -> Retained<NSArray<NSDateComponents>>;
87
88        /// Indicates if a challenge can be attempted more than once.
89        ///
90        /// This property is not atomic.
91        ///
92        /// # Safety
93        ///
94        /// This might not be thread-safe.
95        #[unsafe(method(isRepeatable))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn isRepeatable(&self) -> bool;
98
99        #[cfg(feature = "GKLeaderboard")]
100        /// Scores submitted to this leaderboard will also be submitted as scores in this challenge.
101        ///
102        /// This property is not atomic.
103        ///
104        /// # Safety
105        ///
106        /// This might not be thread-safe.
107        #[unsafe(method(leaderboard))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn leaderboard(&self) -> Option<Retained<GKLeaderboard>>;
110
111        #[cfg(feature = "GKReleaseState")]
112        /// The release state of the challenge definition in App Store Connect.
113        ///
114        /// This property is not atomic.
115        ///
116        /// # Safety
117        ///
118        /// This might not be thread-safe.
119        #[unsafe(method(releaseState))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn releaseState(&self) -> GKReleaseState;
122
123        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
124        #[cfg(target_os = "macos")]
125        /// Loads the image set on the challenge definition, which may be `nil` if none was set.
126        #[unsafe(method(loadImageWithCompletionHandler:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn loadImageWithCompletionHandler(
129            &self,
130            completion_handler: &block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>,
131        );
132    );
133}
134
135/// Methods declared on superclass `NSObject`.
136impl GKChallengeDefinition {
137    extern_methods!(
138        #[unsafe(method(init))]
139        #[unsafe(method_family = init)]
140        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142        #[unsafe(method(new))]
143        #[unsafe(method_family = new)]
144        pub unsafe fn new() -> Retained<Self>;
145    );
146}
147
148/// State.
149impl GKChallengeDefinition {
150    extern_methods!(
151        #[cfg(feature = "block2")]
152        /// Loads all the challenge definitions for the current game, returns an empty array if none exist.
153        /// - Important: Archived challenge definitions are excluded.
154        #[unsafe(method(loadChallengeDefinitionsWithCompletionHandler:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn loadChallengeDefinitionsWithCompletionHandler(
157            completion_handler: &block2::DynBlock<
158                dyn Fn(*mut NSArray<GKChallengeDefinition>, *mut NSError),
159            >,
160        );
161
162        #[cfg(feature = "block2")]
163        /// Indicates if this definition has active challenges associated with it.
164        #[unsafe(method(hasActiveChallengesWithCompletionHandler:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn hasActiveChallengesWithCompletionHandler(
167            &self,
168            completion_handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
169        );
170    );
171}