objc2_game_kit/generated/
GKAchievement.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkachievement?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct GKAchievement;
15);
16
17extern_conformance!(
18    unsafe impl NSCoding for GKAchievement {}
19);
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for GKAchievement {}
23);
24
25extern_conformance!(
26    unsafe impl NSSecureCoding for GKAchievement {}
27);
28
29impl GKAchievement {
30    extern_methods!(
31        #[cfg(feature = "block2")]
32        /// Asynchronously load all achievements for the local player
33        #[unsafe(method(loadAchievementsWithCompletionHandler:))]
34        #[unsafe(method_family = none)]
35        pub unsafe fn loadAchievementsWithCompletionHandler(
36            completion_handler: Option<
37                &block2::DynBlock<dyn Fn(*mut NSArray<GKAchievement>, *mut NSError)>,
38            >,
39        );
40
41        #[cfg(feature = "block2")]
42        /// Reset the achievements progress for the local player. All the entries for the local player are removed from the server. Error will be nil on success.
43        /// Possible reasons for error:
44        /// 1. Local player not authenticated
45        /// 2. Communications failure
46        #[unsafe(method(resetAchievementsWithCompletionHandler:))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn resetAchievementsWithCompletionHandler(
49            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
50        );
51
52        /// Designated initializer
53        #[unsafe(method(initWithIdentifier:))]
54        #[unsafe(method_family = init)]
55        pub unsafe fn initWithIdentifier(
56            this: Allocated<Self>,
57            identifier: &NSString,
58        ) -> Retained<Self>;
59
60        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
61        /// Initialize the achievement for a specific player. Use to submit participant achievements when ending a turn-based match.
62        #[unsafe(method(initWithIdentifier:player:))]
63        #[unsafe(method_family = init)]
64        pub unsafe fn initWithIdentifier_player(
65            this: Allocated<Self>,
66            identifier: &NSString,
67            player: &GKPlayer,
68        ) -> Retained<Self>;
69
70        #[cfg(feature = "block2")]
71        /// Report an array of achievements to the server. Percent complete is required. Points, completed state are set based on percentComplete. isHidden is set to NO anytime this method is invoked. Date is optional. Error will be nil on success.
72        /// Possible reasons for error:
73        /// 1. Local player not authenticated
74        /// 2. Communications failure
75        /// 3. Reported Achievement does not exist
76        #[unsafe(method(reportAchievements:withCompletionHandler:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn reportAchievements_withCompletionHandler(
79            achievements: &NSArray<GKAchievement>,
80            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
81        );
82
83        /// Achievement identifier
84        #[unsafe(method(identifier))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn identifier(&self) -> Retained<NSString>;
87
88        /// Setter for [`identifier`][Self::identifier].
89        ///
90        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
91        #[unsafe(method(setIdentifier:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setIdentifier(&self, identifier: &NSString);
94
95        /// Required, Percentage of achievement complete.
96        #[unsafe(method(percentComplete))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn percentComplete(&self) -> c_double;
99
100        /// Setter for [`percentComplete`][Self::percentComplete].
101        #[unsafe(method(setPercentComplete:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setPercentComplete(&self, percent_complete: c_double);
104
105        /// Set to NO until percentComplete = 100.
106        #[unsafe(method(isCompleted))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn isCompleted(&self) -> bool;
109
110        /// Date the achievement was last reported. Read-only. Created at initialization
111        #[unsafe(method(lastReportedDate))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn lastReportedDate(&self) -> Retained<NSDate>;
114
115        /// A banner will be momentarily displayed after reporting a completed achievement
116        #[unsafe(method(showsCompletionBanner))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn showsCompletionBanner(&self) -> bool;
119
120        /// Setter for [`showsCompletionBanner`][Self::showsCompletionBanner].
121        #[unsafe(method(setShowsCompletionBanner:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn setShowsCompletionBanner(&self, shows_completion_banner: bool);
124
125        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
126        /// The identifier of the player that earned the achievement.
127        #[unsafe(method(player))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn player(&self) -> Retained<GKPlayer>;
130    );
131}
132
133/// Methods declared on superclass `NSObject`.
134impl GKAchievement {
135    extern_methods!(
136        #[unsafe(method(init))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
139
140        #[unsafe(method(new))]
141        #[unsafe(method_family = new)]
142        pub unsafe fn new() -> Retained<Self>;
143    );
144}
145
146/// Deprecated.
147impl GKAchievement {
148    extern_methods!(
149        #[cfg(feature = "block2")]
150        #[deprecated]
151        #[unsafe(method(reportAchievementWithCompletionHandler:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn reportAchievementWithCompletionHandler(
154            &self,
155            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
156        );
157
158        #[deprecated]
159        #[unsafe(method(isHidden))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn isHidden(&self) -> bool;
162    );
163}
164
165/// Obsoleted.
166impl GKAchievement {
167    extern_methods!(
168        /// * This method is obsolete. Calling this initializer does nothing and will return nil **
169        #[deprecated]
170        #[unsafe(method(initWithIdentifier:forPlayer:))]
171        #[unsafe(method_family = init)]
172        pub unsafe fn initWithIdentifier_forPlayer(
173            this: Allocated<Self>,
174            identifier: Option<&NSString>,
175            player_id: &NSString,
176        ) -> Option<Retained<Self>>;
177
178        /// * This property is obsolete. **
179        #[deprecated]
180        #[unsafe(method(playerID))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn playerID(&self) -> Option<Retained<NSString>>;
183    );
184}