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!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengedefinition?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKChallengeDefinition;
);

unsafe impl Send for GKChallengeDefinition {}

unsafe impl Sync for GKChallengeDefinition {}

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

impl GKChallengeDefinition {
    extern_methods!(
        /// The developer defined identifier for a given challenge definition.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        /// The group identifier for the challenge definition, if one exists.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(groupIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn groupIdentifier(&self) -> Option<Retained<NSString>>;

        /// A short title for the challenge definition.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Retained<NSString>;

        /// A more detailed description of the challenge definition.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(details))]
        #[unsafe(method_family = none)]
        pub unsafe fn details(&self) -> Option<Retained<NSString>>;

        /// The duration options for the challenge, like `1 day` or `1 week`.
        /// - Note: If set, the amount of weeks is stored in the `weekOfYear` field.
        /// - Important: The actual duration of the challenge may be dynamically adjusted
        /// in order to accommodate different factors like players' timezones.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(durationOptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn durationOptions(&self) -> Retained<NSArray<NSDateComponents>>;

        /// Indicates if a challenge can be attempted more than once.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(isRepeatable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isRepeatable(&self) -> bool;

        #[cfg(feature = "GKLeaderboard")]
        /// Scores submitted to this leaderboard will also be submitted as scores in this challenge.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(leaderboard))]
        #[unsafe(method_family = none)]
        pub unsafe fn leaderboard(&self) -> Option<Retained<GKLeaderboard>>;

        #[cfg(feature = "GKReleaseState")]
        /// The release state of the challenge definition in App Store Connect.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(releaseState))]
        #[unsafe(method_family = none)]
        pub unsafe fn releaseState(&self) -> GKReleaseState;

        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        /// Loads the image set on the challenge definition, which may be `nil` if none was set.
        #[unsafe(method(loadImageWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadImageWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>,
        );
    );
}

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

/// State.
impl GKChallengeDefinition {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Loads all the challenge definitions for the current game, returns an empty array if none exist.
        /// - Important: Archived challenge definitions are excluded.
        #[unsafe(method(loadChallengeDefinitionsWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadChallengeDefinitionsWithCompletionHandler(
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<GKChallengeDefinition>, *mut NSError),
            >,
        );

        #[cfg(feature = "block2")]
        /// Indicates if this definition has active challenges associated with it.
        #[unsafe(method(hasActiveChallengesWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasActiveChallengesWithCompletionHandler(
            &self,
            completion_handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
        );
    );
}