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
//! 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::*;

/// Possible invitee responses
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviterecipientresponse?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKInviteRecipientResponse(pub NSInteger);
impl GKInviteRecipientResponse {
    #[doc(alias = "GKInviteRecipientResponseAccepted")]
    pub const Accepted: Self = Self(0);
    #[doc(alias = "GKInviteRecipientResponseDeclined")]
    pub const Declined: Self = Self(1);
    #[doc(alias = "GKInviteRecipientResponseFailed")]
    pub const Failed: Self = Self(2);
    #[doc(alias = "GKInviteRecipientResponseIncompatible")]
    pub const Incompatible: Self = Self(3);
    #[doc(alias = "GKInviteRecipientResponseUnableToConnect")]
    pub const UnableToConnect: Self = Self(4);
    #[doc(alias = "GKInviteRecipientResponseNoAnswer")]
    pub const NoAnswer: Self = Self(5);
    #[deprecated]
    pub const GKInviteeResponseAccepted: Self = Self(GKInviteRecipientResponse::Accepted.0);
    #[deprecated]
    pub const GKInviteeResponseDeclined: Self = Self(GKInviteRecipientResponse::Declined.0);
    #[deprecated]
    pub const GKInviteeResponseFailed: Self = Self(GKInviteRecipientResponse::Failed.0);
    #[deprecated]
    pub const GKInviteeResponseIncompatible: Self = Self(GKInviteRecipientResponse::Incompatible.0);
    #[deprecated]
    pub const GKInviteeResponseUnableToConnect: Self =
        Self(GKInviteRecipientResponse::UnableToConnect.0);
    #[deprecated]
    pub const GKInviteeResponseNoAnswer: Self = Self(GKInviteRecipientResponse::NoAnswer.0);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviteeresponse?language=objc)
#[deprecated]
pub type GKInviteeResponse = GKInviteRecipientResponse;

/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKMatchType(pub NSUInteger);
impl GKMatchType {
    #[doc(alias = "GKMatchTypePeerToPeer")]
    pub const PeerToPeer: Self = Self(0);
    #[doc(alias = "GKMatchTypeHosted")]
    pub const Hosted: Self = Self(1);
    #[doc(alias = "GKMatchTypeTurnBased")]
    pub const TurnBased: Self = Self(2);
}

unsafe impl Encode for GKMatchType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    /// GKMatchRequest represents the parameters needed to create the match.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchrequest?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKMatchRequest;
);

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

impl GKMatchRequest {
    extern_methods!(
        /// Minimum number of players for the match
        #[unsafe(method(minPlayers))]
        #[unsafe(method_family = none)]
        pub unsafe fn minPlayers(&self) -> NSUInteger;

        /// Setter for [`minPlayers`][Self::minPlayers].
        #[unsafe(method(setMinPlayers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMinPlayers(&self, min_players: NSUInteger);

        /// Maximum number of players for the match
        #[unsafe(method(maxPlayers))]
        #[unsafe(method_family = none)]
        pub unsafe fn maxPlayers(&self) -> NSUInteger;

        /// Setter for [`maxPlayers`][Self::maxPlayers].
        #[unsafe(method(setMaxPlayers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger);

        /// The player group identifier. Matchmaking will only take place between players in the same group.
        #[unsafe(method(playerGroup))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerGroup(&self) -> NSUInteger;

        /// Setter for [`playerGroup`][Self::playerGroup].
        #[unsafe(method(setPlayerGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger);

        /// optional mask that specifies the role that the local player would like to play in the game.  If this value is 0, it will be set to 0xFFFFFFFF (the default), and this property will be ignored. If the value is nonzero, then automatching uses the value as a mask that restricts the role the player can play in the group. Automatching with player attributes matches new players into the game so that the bitwise OR of the masks of all the players in the resulting match equals 0xFFFFFFFF.
        #[unsafe(method(playerAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerAttributes(&self) -> u32;

        /// Setter for [`playerAttributes`][Self::playerAttributes].
        #[unsafe(method(setPlayerAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayerAttributes(&self, player_attributes: u32);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Array of GKPlayers to invite, or nil if none. This array can also include local guest players.
        #[unsafe(method(recipients))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<GKPlayer>>>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Setter for [`recipients`][Self::recipients].
        #[unsafe(method(setRecipients:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>);

        /// Message sent to invited players, may be modified if using GKMatchmakerViewController
        /// Will return nil if the player is underage or restricted.
        #[unsafe(method(inviteMessage))]
        #[unsafe(method_family = none)]
        pub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>;

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

        /// Default number of players to use during matchmaking. If not set we will default to the number that the player previously set for this game, or maxPlayers.
        #[unsafe(method(defaultNumberOfPlayers))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger;

        /// Setter for [`defaultNumberOfPlayers`][Self::defaultNumberOfPlayers].
        #[unsafe(method(setDefaultNumberOfPlayers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultNumberOfPlayers(&self, default_number_of_players: NSUInteger);

        /// Whether or not a match will be created only using automatch.  If YES, then a player will not be able to
        /// invite anyone (including contacts, friends, and nearby players) to the match, but rely on automatching to
        /// find players for the match.  Default is NO.
        #[deprecated]
        #[unsafe(method(restrictToAutomatch))]
        #[unsafe(method_family = none)]
        pub unsafe fn restrictToAutomatch(&self) -> bool;

        /// Setter for [`restrictToAutomatch`][Self::restrictToAutomatch].
        #[deprecated]
        #[unsafe(method(setRestrictToAutomatch:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        /// An recipientResponseHandler can be set in order to receive responses from programmatically invited players.
        ///
        /// # Safety
        ///
        /// The returned block's argument 1 must be a valid pointer.
        #[unsafe(method(recipientResponseHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipientResponseHandler(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        /// Setter for [`recipientResponseHandler`][Self::recipientResponseHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setRecipientResponseHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRecipientResponseHandler(
            &self,
            recipient_response_handler: Option<
                &block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>,
            >,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block's argument 1 must be a valid pointer.
        #[deprecated]
        #[unsafe(method(inviteeResponseHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn inviteeResponseHandler(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>;

        #[cfg(feature = "block2")]
        /// Setter for [`inviteeResponseHandler`][Self::inviteeResponseHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated]
        #[unsafe(method(setInviteeResponseHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInviteeResponseHandler(
            &self,
            invitee_response_handler: Option<
                &block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>,
            >,
        );

        /// To determine the maximum allowed players for each type of match supported.
        #[unsafe(method(maxPlayersAllowedForMatchOfType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn maxPlayersAllowedForMatchOfType(match_type: GKMatchType) -> NSUInteger;

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

        /// Setter for [`playersToInvite`][Self::playersToInvite].
        #[deprecated]
        #[unsafe(method(setPlayersToInvite:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayersToInvite(&self, players_to_invite: Option<&NSArray<NSString>>);

        /// The name of the queue, if rule-based matchmaking is used.
        #[unsafe(method(queueName))]
        #[unsafe(method_family = none)]
        pub unsafe fn queueName(&self) -> Option<Retained<NSString>>;

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

        #[cfg(feature = "GKDefines")]
        /// The match properties, if rule-based matchmaking is used.
        #[unsafe(method(properties))]
        #[unsafe(method_family = none)]
        pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;

        #[cfg(feature = "GKDefines")]
        /// Setter for [`properties`][Self::properties].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `properties` generic should be of the correct type.
        #[unsafe(method(setProperties:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProperties(&self, properties: Option<&GKMatchProperties>);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
        /// The recipient specific match properties, if rule-based matchmaking is used when inviting players.
        #[unsafe(method(recipientProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipientProperties(
            &self,
        ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
        /// Setter for [`recipientProperties`][Self::recipientProperties].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `recipient_properties` generic generic should be of the correct type.
        #[unsafe(method(setRecipientProperties:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRecipientProperties(
            &self,
            recipient_properties: Option<&NSDictionary<GKPlayer, GKMatchProperties>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GKMatchRequest {
    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!(
    /// GKInvite represents an accepted game invite, it is used to create a GKMatchmakerViewController
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinvite?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKInvite;
);

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

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

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

        /// player group from inviter's match request
        #[unsafe(method(playerGroup))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerGroup(&self) -> NSUInteger;

        /// player attributes from inviter's match request
        #[unsafe(method(playerAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerAttributes(&self) -> u32;

        /// * This property is obsolete. **
        #[deprecated]
        #[unsafe(method(inviter))]
        #[unsafe(method_family = none)]
        pub unsafe fn inviter(&self) -> Retained<NSString>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKInvite {
    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!(
    /// GKInviteEventListener uses the GKLocalPlayerListener mechanism on GKLocalPlayer to listen to the two kinds of invite events that a game must respond to
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviteeventlistener?language=objc)
    pub unsafe trait GKInviteEventListener {
        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// player:didAcceptInvite: gets called when another player accepts the invite from the local player
        #[optional]
        #[unsafe(method(player:didAcceptInvite:))]
        #[unsafe(method_family = none)]
        unsafe fn player_didAcceptInvite(&self, player: &GKPlayer, invite: &GKInvite);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// didRequestMatchWithRecipients: gets called when the player chooses to play with another player from Game Center and it launches the game to start matchmaking
        #[optional]
        #[unsafe(method(player:didRequestMatchWithRecipients:))]
        #[unsafe(method_family = none)]
        unsafe fn player_didRequestMatchWithRecipients(
            &self,
            player: &GKPlayer,
            recipient_players: &NSArray<GKPlayer>,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
        #[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_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchedplayers?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKMatchedPlayers;
);

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

impl GKMatchedPlayers {
    extern_methods!(
        #[cfg(feature = "GKDefines")]
        #[unsafe(method(properties))]
        #[unsafe(method_family = none)]
        pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        #[unsafe(method(players))]
        #[unsafe(method_family = none)]
        pub unsafe fn players(&self) -> Retained<NSArray<GKPlayer>>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
        #[unsafe(method(playerProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerProperties(
            &self,
        ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKMatchedPlayers {
    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!(
    /// GKMatchmaker is a singleton object to manage match creation from invites and automatching.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmaker?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKMatchmaker;
);

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

impl GKMatchmaker {
    extern_methods!(
        /// The shared matchmaker
        #[unsafe(method(sharedMatchmaker))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedMatchmaker() -> Retained<GKMatchmaker>;

        #[cfg(all(feature = "GKMatch", feature = "block2"))]
        /// Get a match for an accepted invite
        /// Possible reasons for error:
        /// 1. Communications failure
        /// 2. Invite cancelled
        #[unsafe(method(matchForInvite:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchForInvite_completionHandler(
            &self,
            invite: &GKInvite,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
        );

        #[cfg(all(feature = "GKMatch", feature = "block2"))]
        /// Automatching or invites to find a peer-to-peer match for the specified request. Error will be nil on success:
        /// Possible reasons for error:
        /// 1. Communications failure
        /// 2. Unauthenticated player
        /// 3. Timeout
        /// Note that the players property on the returned GKMatch instance will only contain connected players. It will initially be empty as players are connecting. Implement the GKMatchDelegate method match:player:didChangeConnectionState: to listen for updates to the GKMatch instance's players property.
        #[unsafe(method(findMatchForRequest:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findMatchForRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        /// Automatching or invites for host-client match request. This returns a list of player identifiers to be included in the match. Determination and communication with the host is not part of this API.
        /// When inviting, no player identifiers will be returned. Player responses will be reported via the inviteeResponseHandler.
        /// Possible reasons for error:
        /// 1. Communications failure
        /// 2. Unauthenticated player
        /// 3. Timeout
        #[unsafe(method(findPlayersForHostedRequest:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findPlayersForHostedRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
            >,
        );

        #[cfg(feature = "block2")]
        /// Automatching or invites for host-client rule-based match request.
        #[unsafe(method(findMatchedPlayers:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findMatchedPlayers_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: &block2::DynBlock<dyn Fn(*mut GKMatchedPlayers, *mut NSError)>,
        );

        #[cfg(all(feature = "GKMatch", feature = "block2"))]
        /// Automatching or invites to add additional players to a peer-to-peer match for the specified request. Error will be nil on success:
        /// Possible reasons for error:
        /// 1. Communications failure
        /// 2. Timeout
        #[unsafe(method(addPlayersToMatch:matchRequest:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addPlayersToMatch_matchRequest_completionHandler(
            &self,
            r#match: &GKMatch,
            match_request: &GKMatchRequest,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        /// Cancel matchmaking and any pending invites
        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancel(&self);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Cancel a pending invitation to a player
        #[unsafe(method(cancelPendingInviteToPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelPendingInviteToPlayer(&self, player: &GKPlayer);

        #[cfg(feature = "GKMatch")]
        /// Call this when finished with all programmatic P2P invites/matchmaking, for compatability with connected players using GKMatchmakerViewController.
        #[unsafe(method(finishMatchmakingForMatch:))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishMatchmakingForMatch(&self, r#match: &GKMatch);

        #[cfg(feature = "block2")]
        /// Query the server for recent activity in the specified player group. A larger value indicates that a given group has seen more recent activity. Error will be nil on success.
        /// Possible reasons for error:
        /// 1. Communications failure
        #[unsafe(method(queryPlayerGroupActivity:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryPlayerGroupActivity_withCompletionHandler(
            &self,
            player_group: NSUInteger,
            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// Query the server for recent activity for all the player groups of that game. Error will be nil on success.
        /// Possible reasons for error:
        /// 1. Communications failure
        #[unsafe(method(queryActivityWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryActivityWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// Query the server for recent activity for the specified queue.
        #[unsafe(method(queryQueueActivity:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryQueueActivity_withCompletionHandler(
            &self,
            queue_name: &NSString,
            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
        );

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        /// Start browsing for nearby players that can be invited to a match. The reachableHandler will be called for each player found with a compatible game. It may be called more than once for the same player if that player ever becomes unreachable (e.g. moves out of range). You should call stopBrowsingForNearbyPlayers when finished browsing.
        #[unsafe(method(startBrowsingForNearbyPlayersWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startBrowsingForNearbyPlayersWithHandler(
            &self,
            reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKPlayer>, Bool)>>,
        );

        /// Stop browsing for nearby players.
        #[unsafe(method(stopBrowsingForNearbyPlayers))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopBrowsingForNearbyPlayers(&self);

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
        /// Activate  a  group activity by Game Center for your game, which allows people in the FaceTime call to join the local player's game. The handler will be called for each player who joined from the activity.
        #[unsafe(method(startGroupActivityWithPlayerHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startGroupActivityWithPlayerHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(NonNull<GKPlayer>)>,
        );

        /// End the group activity created by Game Center for your game, which was activated by the local player.
        #[unsafe(method(stopGroupActivity))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopGroupActivity(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl GKMatchmaker {
    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>;
    );
}

/// GKDeprecated.
impl GKMatchmaker {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer.
        /// - The returned block's argument 2 must be a valid pointer or null.
        #[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
        #[unsafe(method(inviteHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn inviteHandler(
            &self,
        ) -> *mut block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>;

        #[cfg(feature = "block2")]
        /// Setter for [`inviteHandler`][Self::inviteHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
        #[unsafe(method(setInviteHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInviteHandler(
            &self,
            invite_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>>,
        );
    );
}

/// Obsoleted.
impl GKMatchmaker {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
        #[deprecated]
        #[unsafe(method(startBrowsingForNearbyPlayersWithReachableHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startBrowsingForNearbyPlayersWithReachableHandler(
            &self,
            reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<NSString>, Bool)>>,
        );

        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
        #[deprecated]
        #[unsafe(method(cancelInviteToPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelInviteToPlayer(&self, player_id: &NSString);

        #[cfg(feature = "block2")]
        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
        #[deprecated]
        #[unsafe(method(findPlayersForHostedMatchRequest:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findPlayersForHostedMatchRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<NSString>, *mut NSError)>,
            >,
        );
    );
}