objc2-game-kit 0.3.2

Bindings to the GameKit framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// GKLeaderboardSet represents the sets that leaderboards can be broken out into.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkleaderboardset?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKLeaderboardSet;
);

extern_conformance!(
    unsafe impl NSCoding for GKLeaderboardSet {}
);

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

extern_conformance!(
    unsafe impl NSSecureCoding for GKLeaderboardSet {}
);

impl GKLeaderboardSet {
    extern_methods!(
        /// Localized set title.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Retained<NSString>;

        /// set when leaderboardSets have been designated a game group; set when loadLeaderboardSetsWithCompletionHandler has been called for leaderboards that support game groups
        #[unsafe(method(groupIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn groupIdentifier(&self) -> Option<Retained<NSString>>;

        /// leaderboard set.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Option<Retained<NSString>>;

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

        #[cfg(feature = "block2")]
        /// Loads array with all sets for game
        /// Possible reasons for error:
        /// 1. Communications problem
        /// 2. Unauthenticated player
        /// 3. Set not present
        #[unsafe(method(loadLeaderboardSetsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadLeaderboardSetsWithCompletionHandler(
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKLeaderboardSet>, *mut NSError)>,
            >,
        );

        #[cfg(all(feature = "GKLeaderboard", feature = "block2"))]
        /// Loads array with all classic leaderboards and current instances of recurring leaderboards for this leaderboardSet
        /// Possible reasons for error:
        /// 1. Communications problem
        /// 2. Unauthenticated player
        #[unsafe(method(loadLeaderboardsWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadLeaderboardsWithHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(*mut NSArray<GKLeaderboard>, *mut NSError)>,
        );
    );
}

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

/// Deprecated.
impl GKLeaderboardSet {
    extern_methods!(
        #[cfg(all(feature = "GKLeaderboard", feature = "block2"))]
        /// Loads array with all leaderboards for the leaderboardSet
        /// Possible reasons for error:
        /// 1. Communications problem
        /// 2. Unauthenticated player
        #[deprecated]
        #[unsafe(method(loadLeaderboardsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadLeaderboardsWithCompletionHandler(
            &self,
            completion_handler: Option<
                &block2::DynBlock<dyn Fn(*mut NSArray<GKLeaderboard>, *mut NSError)>,
            >,
        );
    );
}

/// UI.
impl GKLeaderboardSet {
    extern_methods!(
        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        /// Asynchronously load the image. Error will be nil on success.
        #[unsafe(method(loadImageWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadImageWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>>,
        );
    );
}