objc2-game-kit 0.3.2

Bindings to the GameKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Constants that describe the state of the overall match
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedmatchstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKTurnBasedMatchStatus(pub NSInteger);
impl GKTurnBasedMatchStatus {
    #[doc(alias = "GKTurnBasedMatchStatusUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "GKTurnBasedMatchStatusOpen")]
    pub const Open: Self = Self(1);
    #[doc(alias = "GKTurnBasedMatchStatusEnded")]
    pub const Ended: Self = Self(2);
    #[doc(alias = "GKTurnBasedMatchStatusMatching")]
    pub const Matching: Self = Self(3);
}

unsafe impl Encode for GKTurnBasedMatchStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for GKTurnBasedMatchStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Constants that describe the state of individual participants in the match
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedparticipantstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKTurnBasedParticipantStatus(pub NSInteger);
impl GKTurnBasedParticipantStatus {
    #[doc(alias = "GKTurnBasedParticipantStatusUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "GKTurnBasedParticipantStatusInvited")]
    pub const Invited: Self = Self(1);
    #[doc(alias = "GKTurnBasedParticipantStatusDeclined")]
    pub const Declined: Self = Self(2);
    #[doc(alias = "GKTurnBasedParticipantStatusMatching")]
    pub const Matching: Self = Self(3);
    #[doc(alias = "GKTurnBasedParticipantStatusActive")]
    pub const Active: Self = Self(4);
    #[doc(alias = "GKTurnBasedParticipantStatusDone")]
    pub const Done: Self = Self(5);
}

unsafe impl Encode for GKTurnBasedParticipantStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for GKTurnBasedParticipantStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Constants that describe the game result for a given participant who has reached the done state.  The developer is free to use these constants or add additional ones
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedmatchoutcome?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKTurnBasedMatchOutcome(pub NSInteger);
impl GKTurnBasedMatchOutcome {
    #[doc(alias = "GKTurnBasedMatchOutcomeNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "GKTurnBasedMatchOutcomeQuit")]
    pub const Quit: Self = Self(1);
    #[doc(alias = "GKTurnBasedMatchOutcomeWon")]
    pub const Won: Self = Self(2);
    #[doc(alias = "GKTurnBasedMatchOutcomeLost")]
    pub const Lost: Self = Self(3);
    #[doc(alias = "GKTurnBasedMatchOutcomeTied")]
    pub const Tied: Self = Self(4);
    #[doc(alias = "GKTurnBasedMatchOutcomeTimeExpired")]
    pub const TimeExpired: Self = Self(5);
    #[doc(alias = "GKTurnBasedMatchOutcomeFirst")]
    pub const First: Self = Self(6);
    #[doc(alias = "GKTurnBasedMatchOutcomeSecond")]
    pub const Second: Self = Self(7);
    #[doc(alias = "GKTurnBasedMatchOutcomeThird")]
    pub const Third: Self = Self(8);
    #[doc(alias = "GKTurnBasedMatchOutcomeFourth")]
    pub const Fourth: Self = Self(9);
    #[doc(alias = "GKTurnBasedMatchOutcomeCustomRange")]
    pub const CustomRange: Self = Self(0x00FF0000);
}

unsafe impl Encode for GKTurnBasedMatchOutcome {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for GKTurnBasedMatchOutcome {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// GKTurnBasedMatch represents an ongoing turn-based game among the matched group of participants
    /// Existing matches can be shown and new matches created using GKTurnBasedMatchmakerViewController
    /// A list of existing matches can be retrieved using +loadMatchesWithCompletionHandler:
    ///
    /// By default turn based events will badge your app.  To opt out of this add GKGameCenterBadgingDisabled  with a boolean value of YES to your info plist
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedparticipant?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKTurnBasedParticipant;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKTurnBasedParticipant {}
);

impl GKTurnBasedParticipant {
    extern_methods!(
        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        #[unsafe(method(player))]
        #[unsafe(method_family = none)]
        pub unsafe fn player(&self) -> Option<Retained<GKPlayer>>;

        #[unsafe(method(lastTurnDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn lastTurnDate(&self) -> Option<Retained<NSDate>>;

        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> GKTurnBasedParticipantStatus;

        #[unsafe(method(matchOutcome))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchOutcome(&self) -> GKTurnBasedMatchOutcome;

        /// Setter for [`matchOutcome`][Self::matchOutcome].
        #[unsafe(method(setMatchOutcome:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMatchOutcome(&self, match_outcome: GKTurnBasedMatchOutcome);

        #[unsafe(method(timeoutDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeoutDate(&self) -> Option<Retained<NSDate>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKTurnBasedParticipant {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// Obsoleted.
impl GKTurnBasedParticipant {
    extern_methods!(
        /// * This property is obsolete. **
        #[deprecated]
        #[unsafe(method(playerID))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerID(&self) -> Option<Retained<NSString>>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedeventlistener?language=objc)
    pub unsafe trait GKTurnBasedEventListener {
        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// If Game Center initiates a match the developer should create a GKTurnBasedMatch from playersToInvite and present a GKTurnbasedMatchmakerViewController.
        #[optional]
        #[unsafe(method(player:didRequestMatchWithOtherPlayers:))]
        #[unsafe(method_family = none)]
        unsafe fn player_didRequestMatchWithOtherPlayers(
            &self,
            player: &GKPlayer,
            players_to_invite: &NSArray<GKPlayer>,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// called when it becomes this player's turn.  It also gets called under the following conditions:
        /// the player's turn has a timeout and it is about to expire.
        /// the player accepts an invite from another player.
        /// when the game is running it will additionally recieve turn events for the following:
        /// turn was passed to another player
        /// another player saved the match data
        /// Because of this the app needs to be prepared to handle this even while the player is taking a turn in an existing match.  The boolean indicates whether this event launched or brought to forground the app.
        #[optional]
        #[unsafe(method(player:receivedTurnEventForMatch:didBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn player_receivedTurnEventForMatch_didBecomeActive(
            &self,
            player: &GKPlayer,
            r#match: &GKTurnBasedMatch,
            did_become_active: bool,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// called when the match has ended.
        #[optional]
        #[unsafe(method(player:matchEnded:))]
        #[unsafe(method_family = none)]
        unsafe fn player_matchEnded(&self, player: &GKPlayer, r#match: &GKTurnBasedMatch);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// this is called when a player receives an exchange request from another player.
        #[optional]
        #[unsafe(method(player:receivedExchangeRequest:forMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn player_receivedExchangeRequest_forMatch(
            &self,
            player: &GKPlayer,
            exchange: &GKTurnBasedExchange,
            r#match: &GKTurnBasedMatch,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// this is called when an exchange is canceled by the sender.
        #[optional]
        #[unsafe(method(player:receivedExchangeCancellation:forMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn player_receivedExchangeCancellation_forMatch(
            &self,
            player: &GKPlayer,
            exchange: &GKTurnBasedExchange,
            r#match: &GKTurnBasedMatch,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// called when all players either respond or timeout responding to this request.  This is sent to both the turn holder and the initiator of the exchange
        #[optional]
        #[unsafe(method(player:receivedExchangeReplies:forCompletedExchange:forMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn player_receivedExchangeReplies_forCompletedExchange_forMatch(
            &self,
            player: &GKPlayer,
            replies: &NSArray<GKTurnBasedExchangeReply>,
            exchange: &GKTurnBasedExchange,
            r#match: &GKTurnBasedMatch,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Called when a player chooses to quit a match and that player has the current turn.  The developer should call participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:matchData:completionHandler: on the match passing in appropriate values.  They can also update matchOutcome for other players as appropriate.
        #[optional]
        #[unsafe(method(player:wantsToQuitMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn player_wantsToQuitMatch(&self, player: &GKPlayer, r#match: &GKTurnBasedMatch);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Deprecated
        #[deprecated]
        #[optional]
        #[unsafe(method(player:didRequestMatchWithPlayers:))]
        #[unsafe(method_family = none)]
        unsafe fn player_didRequestMatchWithPlayers(
            &self,
            player: &GKPlayer,
            player_i_ds_to_invite: &NSArray<NSString>,
        );
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturntimeoutdefault?language=objc)
    pub static GKTurnTimeoutDefault: NSTimeInterval;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturntimeoutnone?language=objc)
    pub static GKTurnTimeoutNone: NSTimeInterval;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedmatch?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKTurnBasedMatch;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKTurnBasedMatch {}
);

impl GKTurnBasedMatch {
    extern_methods!(
        #[unsafe(method(matchID))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchID(&self) -> Retained<NSString>;

        #[unsafe(method(creationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationDate(&self) -> Retained<NSDate>;

        #[unsafe(method(participants))]
        #[unsafe(method_family = none)]
        pub unsafe fn participants(&self) -> Retained<NSArray<GKTurnBasedParticipant>>;

        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> GKTurnBasedMatchStatus;

        #[unsafe(method(currentParticipant))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentParticipant(&self) -> Option<Retained<GKTurnBasedParticipant>>;

        #[unsafe(method(matchData))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchData(&self) -> Option<Retained<NSData>>;

        #[unsafe(method(setLocalizableMessageWithKey:arguments:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocalizableMessageWithKey_arguments(
            &self,
            key: &NSString,
            arguments: Option<&NSArray<NSString>>,
        );

        #[unsafe(method(message))]
        #[unsafe(method_family = none)]
        pub unsafe fn message(&self) -> Option<Retained<NSString>>;

        /// Setter for [`message`][Self::message].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMessage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMessage(&self, message: Option<&NSString>);

        #[unsafe(method(matchDataMaximumSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchDataMaximumSize(&self) -> NSUInteger;

        #[unsafe(method(exchanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchanges(&self) -> Option<Retained<NSArray<GKTurnBasedExchange>>>;

        #[unsafe(method(activeExchanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn activeExchanges(&self) -> Option<Retained<NSArray<GKTurnBasedExchange>>>;

        #[unsafe(method(completedExchanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn completedExchanges(&self) -> Option<Retained<NSArray<GKTurnBasedExchange>>>;

        #[unsafe(method(exchangeDataMaximumSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchangeDataMaximumSize(&self) -> NSUInteger;

        #[unsafe(method(exchangeMaxInitiatedExchangesPerPlayer))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchangeMaxInitiatedExchangesPerPlayer(&self) -> NSUInteger;

        #[cfg(all(feature = "GKMatchmaker", feature = "block2"))]
        #[unsafe(method(findMatchForRequest:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findMatchForRequest_withCompletionHandler(
            request: &GKMatchRequest,
            completion_handler: &block2::DynBlock<dyn Fn(*mut GKTurnBasedMatch, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(loadMatchesWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadMatchesWithCompletionHandler(
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKTurnBasedMatch>, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(loadMatchWithID:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadMatchWithID_withCompletionHandler(
            match_id: &NSString,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut GKTurnBasedMatch, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(rematchWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn rematchWithCompletionHandler(
            &self,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut GKTurnBasedMatch, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(acceptInviteWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn acceptInviteWithCompletionHandler(
            &self,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut GKTurnBasedMatch, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(declineInviteWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn declineInviteWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(removeWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(loadMatchDataWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadMatchDataWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(endTurnWithNextParticipants:turnTimeout:matchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endTurnWithNextParticipants_turnTimeout_matchData_completionHandler(
            &self,
            next_participants: &NSArray<GKTurnBasedParticipant>,
            timeout: NSTimeInterval,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:matchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn participantQuitInTurnWithOutcome_nextParticipants_turnTimeout_matchData_completionHandler(
            &self,
            match_outcome: GKTurnBasedMatchOutcome,
            next_participants: &NSArray<GKTurnBasedParticipant>,
            timeout: NSTimeInterval,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(participantQuitOutOfTurnWithOutcome:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn participantQuitOutOfTurnWithOutcome_withCompletionHandler(
            &self,
            match_outcome: GKTurnBasedMatchOutcome,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(endMatchInTurnWithMatchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endMatchInTurnWithMatchData_completionHandler(
            &self,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(all(feature = "GKAchievement", feature = "GKScore", feature = "block2"))]
        #[deprecated]
        #[unsafe(method(endMatchInTurnWithMatchData:scores:achievements:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endMatchInTurnWithMatchData_scores_achievements_completionHandler(
            &self,
            match_data: &NSData,
            scores: Option<&NSArray<GKScore>>,
            achievements: Option<&NSArray<GKAchievement>>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(all(feature = "GKLeaderboardScore", feature = "block2"))]
        /// # Safety
        ///
        /// `achievements` generic should be of the correct type.
        #[unsafe(method(endMatchInTurnWithMatchData:leaderboardScores:achievements:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endMatchInTurnWithMatchData_leaderboardScores_achievements_completionHandler(
            &self,
            match_data: &NSData,
            scores: &NSArray<GKLeaderboardScore>,
            achievements: &NSArray,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(saveCurrentTurnWithMatchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveCurrentTurnWithMatchData_completionHandler(
            &self,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(saveMergedMatchData:withResolvedExchanges:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveMergedMatchData_withResolvedExchanges_completionHandler(
            &self,
            match_data: &NSData,
            exchanges: &NSArray<GKTurnBasedExchange>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(sendExchangeToParticipants:data:localizableMessageKey:arguments:timeout:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendExchangeToParticipants_data_localizableMessageKey_arguments_timeout_completionHandler(
            &self,
            participants: &NSArray<GKTurnBasedParticipant>,
            data: &NSData,
            key: &NSString,
            arguments: &NSArray<NSString>,
            timeout: NSTimeInterval,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut GKTurnBasedExchange, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(sendReminderToParticipants:localizableMessageKey:arguments:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendReminderToParticipants_localizableMessageKey_arguments_completionHandler(
            &self,
            participants: &NSArray<GKTurnBasedParticipant>,
            key: &NSString,
            arguments: &NSArray<NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[deprecated]
        #[unsafe(method(endTurnWithNextParticipant:matchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endTurnWithNextParticipant_matchData_completionHandler(
            &self,
            next_participant: &GKTurnBasedParticipant,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[deprecated]
        #[unsafe(method(participantQuitInTurnWithOutcome:nextParticipant:matchData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn participantQuitInTurnWithOutcome_nextParticipant_matchData_completionHandler(
            &self,
            match_outcome: GKTurnBasedMatchOutcome,
            next_participant: &GKTurnBasedParticipant,
            match_data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GKTurnBasedMatch {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedexchangestatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKTurnBasedExchangeStatus(pub i8);
impl GKTurnBasedExchangeStatus {
    #[doc(alias = "GKTurnBasedExchangeStatusUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "GKTurnBasedExchangeStatusActive")]
    pub const Active: Self = Self(1);
    #[doc(alias = "GKTurnBasedExchangeStatusComplete")]
    pub const Complete: Self = Self(2);
    #[doc(alias = "GKTurnBasedExchangeStatusResolved")]
    pub const Resolved: Self = Self(3);
    #[doc(alias = "GKTurnBasedExchangeStatusCanceled")]
    pub const Canceled: Self = Self(4);
}

unsafe impl Encode for GKTurnBasedExchangeStatus {
    const ENCODING: Encoding = i8::ENCODING;
}

unsafe impl RefEncode for GKTurnBasedExchangeStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkexchangetimeoutdefault?language=objc)
    pub static GKExchangeTimeoutDefault: NSTimeInterval;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkexchangetimeoutnone?language=objc)
    pub static GKExchangeTimeoutNone: NSTimeInterval;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedexchange?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKTurnBasedExchange;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKTurnBasedExchange {}
);

impl GKTurnBasedExchange {
    extern_methods!(
        #[unsafe(method(exchangeID))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchangeID(&self) -> Retained<NSString>;

        #[unsafe(method(sender))]
        #[unsafe(method_family = none)]
        pub unsafe fn sender(&self) -> Retained<GKTurnBasedParticipant>;

        #[unsafe(method(recipients))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipients(&self) -> Retained<NSArray<GKTurnBasedParticipant>>;

        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> GKTurnBasedExchangeStatus;

        #[unsafe(method(message))]
        #[unsafe(method_family = none)]
        pub unsafe fn message(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub unsafe fn data(&self) -> Option<Retained<NSData>>;

        #[unsafe(method(sendDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendDate(&self) -> Retained<NSDate>;

        #[unsafe(method(timeoutDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeoutDate(&self) -> Option<Retained<NSDate>>;

        #[unsafe(method(completionDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn completionDate(&self) -> Option<Retained<NSDate>>;

        #[unsafe(method(replies))]
        #[unsafe(method_family = none)]
        pub unsafe fn replies(&self) -> Option<Retained<NSArray<GKTurnBasedExchangeReply>>>;

        #[cfg(feature = "block2")]
        #[unsafe(method(cancelWithLocalizableMessageKey:arguments:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelWithLocalizableMessageKey_arguments_completionHandler(
            &self,
            key: &NSString,
            arguments: &NSArray<NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[unsafe(method(replyWithLocalizableMessageKey:arguments:data:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replyWithLocalizableMessageKey_arguments_data_completionHandler(
            &self,
            key: &NSString,
            arguments: &NSArray<NSString>,
            data: &NSData,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GKTurnBasedExchange {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedexchangereply?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKTurnBasedExchangeReply;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKTurnBasedExchangeReply {}
);

impl GKTurnBasedExchangeReply {
    extern_methods!(
        #[unsafe(method(recipient))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipient(&self) -> Retained<GKTurnBasedParticipant>;

        #[unsafe(method(message))]
        #[unsafe(method_family = none)]
        pub unsafe fn message(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub unsafe fn data(&self) -> Option<Retained<NSData>>;

        #[unsafe(method(replyDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn replyDate(&self) -> Retained<NSDate>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKTurnBasedExchangeReply {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedeventhandlerdelegate?language=objc)
    #[deprecated]
    pub unsafe trait GKTurnBasedEventHandlerDelegate {
        #[deprecated]
        #[unsafe(method(handleInviteFromGameCenter:))]
        #[unsafe(method_family = none)]
        unsafe fn handleInviteFromGameCenter(&self, players_to_invite: &NSArray<NSString>);

        #[deprecated]
        #[unsafe(method(handleTurnEventForMatch:didBecomeActive:))]
        #[unsafe(method_family = none)]
        unsafe fn handleTurnEventForMatch_didBecomeActive(
            &self,
            r#match: &GKTurnBasedMatch,
            did_become_active: bool,
        );

        #[deprecated]
        #[optional]
        #[unsafe(method(handleTurnEventForMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn handleTurnEventForMatch(&self, r#match: &GKTurnBasedMatch);

        #[deprecated]
        #[optional]
        #[unsafe(method(handleMatchEnded:))]
        #[unsafe(method_family = none)]
        unsafe fn handleMatchEnded(&self, r#match: &GKTurnBasedMatch);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkturnbasedeventhandler?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated]
    pub struct GKTurnBasedEventHandler;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKTurnBasedEventHandler {}
);

impl GKTurnBasedEventHandler {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(sharedTurnBasedEventHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedTurnBasedEventHandler() -> Retained<GKTurnBasedEventHandler>;

        #[deprecated]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<NSObject>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `delegate` must implement GKTurnBasedEventHandlerDelegate.
        #[deprecated]
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&NSObject>);
    );
}

/// Methods declared on superclass `NSObject`.
impl GKTurnBasedEventHandler {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}