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::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// GKScore represents a score in the leaderboards.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkscore?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated]
    pub struct GKScore;
);

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

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

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

impl GKScore {
    extern_methods!(
        /// Initialize the score with the local player and current date.
        #[deprecated]
        #[unsafe(method(initWithLeaderboardIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboardIdentifier(
            this: Allocated<Self>,
            identifier: &NSString,
        ) -> Retained<Self>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// Initialize the achievement for a specific player. Use to submit participant scores when ending a turn-based match.
        #[deprecated]
        #[unsafe(method(initWithLeaderboardIdentifier:player:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboardIdentifier_player(
            this: Allocated<Self>,
            identifier: &NSString,
            player: &GKPlayer,
        ) -> Retained<Self>;

        /// The score value as a 64bit integer.
        #[deprecated]
        #[unsafe(method(value))]
        #[unsafe(method_family = none)]
        pub unsafe fn value(&self) -> i64;

        /// Setter for [`value`][Self::value].
        #[deprecated]
        #[unsafe(method(setValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue(&self, value: i64);

        /// The score formatted as a string, localized with a label
        #[deprecated]
        #[unsafe(method(formattedValue))]
        #[unsafe(method_family = none)]
        pub unsafe fn formattedValue(&self) -> Option<Retained<NSString>>;

        /// leaderboard identifier (required)
        #[deprecated]
        #[unsafe(method(leaderboardIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn leaderboardIdentifier(&self) -> Retained<NSString>;

        /// Setter for [`leaderboardIdentifier`][Self::leaderboardIdentifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[deprecated]
        #[unsafe(method(setLeaderboardIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLeaderboardIdentifier(&self, leaderboard_identifier: &NSString);

        /// optional additional context that allows a game to store and retrieve additional data associated with the store.  Default value of zero is returned if no value is set.
        #[deprecated]
        #[unsafe(method(context))]
        #[unsafe(method_family = none)]
        pub unsafe fn context(&self) -> u64;

        /// Setter for [`context`][Self::context].
        #[deprecated]
        #[unsafe(method(setContext:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContext(&self, context: u64);

        /// The date this score was recorded. A newly initialized, unsubmitted GKScore records the current date at init time.
        #[deprecated]
        #[unsafe(method(date))]
        #[unsafe(method_family = none)]
        pub unsafe fn date(&self) -> Retained<NSDate>;

        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
        /// The player that recorded the score.
        #[deprecated]
        #[unsafe(method(player))]
        #[unsafe(method_family = none)]
        pub unsafe fn player(&self) -> Retained<GKPlayer>;

        /// The rank of the player within the leaderboard, only valid when returned from GKLeaderboard
        #[deprecated]
        #[unsafe(method(rank))]
        #[unsafe(method_family = none)]
        pub unsafe fn rank(&self) -> NSInteger;

        /// Convenience property to make the leaderboard associated with this GKScore, the default leaderboard for this player. Default value is false.
        /// If true, reporting that score will make the category this score belongs to, the default leaderboard for this user
        #[deprecated]
        #[unsafe(method(shouldSetDefaultLeaderboard))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldSetDefaultLeaderboard(&self) -> bool;

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

        #[cfg(feature = "block2")]
        /// Report scores to the server. The value must be set, and date may be changed.
        /// Possible reasons for error:
        /// 1. Value not set
        /// 2. Local player not authenticated
        /// 3. Communications problem
        #[deprecated]
        #[unsafe(method(reportScores:withCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn reportScores_withCompletionHandler(
            scores: &NSArray<GKScore>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GKScore {
    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.
#[deprecated]
impl GKScore {
    extern_methods!(
        #[cfg(feature = "block2")]
        #[deprecated]
        #[unsafe(method(reportScoreWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn reportScoreWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[deprecated]
        #[unsafe(method(initWithCategory:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCategory(
            this: Allocated<Self>,
            category: Option<&NSString>,
        ) -> Retained<Self>;

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

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

/// Obsoleted.
impl GKScore {
    extern_methods!(
        /// * This method is obsolete. Calling this initialiser does nothing and will return nil **
        #[deprecated]
        #[unsafe(method(initWithLeaderboardIdentifier:forPlayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLeaderboardIdentifier_forPlayer(
            this: Allocated<Self>,
            identifier: &NSString,
            player_id: &NSString,
        ) -> Option<Retained<Self>>;

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