//! 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!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsuserdefaultscontroller?language=objc)
    #[unsafe(super(NSController, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSController")]
    pub struct NSUserDefaultsController;
);

#[cfg(feature = "NSController")]
extern_conformance!(
    unsafe impl NSCoding for NSUserDefaultsController {}
);

#[cfg(all(feature = "NSController", feature = "NSKeyValueBinding"))]
extern_conformance!(
    unsafe impl NSEditor for NSUserDefaultsController {}
);

#[cfg(all(feature = "NSController", feature = "NSKeyValueBinding"))]
extern_conformance!(
    unsafe impl NSEditorRegistration for NSUserDefaultsController {}
);

#[cfg(feature = "NSController")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSUserDefaultsController {}
);

#[cfg(feature = "NSController")]
impl NSUserDefaultsController {
    extern_methods!(
        #[unsafe(method(sharedUserDefaultsController))]
        #[unsafe(method_family = none)]
        pub fn sharedUserDefaultsController(
            mtm: MainThreadMarker,
        ) -> Retained<NSUserDefaultsController>;

        /// # Safety
        ///
        /// `initial_values` generic should be of the correct type.
        #[unsafe(method(initWithDefaults:initialValues:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDefaults_initialValues(
            this: Allocated<Self>,
            defaults: Option<&NSUserDefaults>,
            initial_values: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

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

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

        /// Setter for [`initialValues`][Self::initialValues].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `initial_values` generic should be of the correct type.
        #[unsafe(method(setInitialValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInitialValues(
            &self,
            initial_values: Option<&NSDictionary<NSString, AnyObject>>,
        );

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

        /// Setter for [`appliesImmediately`][Self::appliesImmediately].
        #[unsafe(method(setAppliesImmediately:))]
        #[unsafe(method_family = none)]
        pub fn setAppliesImmediately(&self, applies_immediately: bool);

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

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

        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[unsafe(method(revert:))]
        #[unsafe(method_family = none)]
        pub unsafe fn revert(&self, sender: Option<&AnyObject>);

        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[unsafe(method(save:))]
        #[unsafe(method_family = none)]
        pub unsafe fn save(&self, sender: Option<&AnyObject>);

        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[unsafe(method(revertToInitialValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn revertToInitialValues(&self, sender: Option<&AnyObject>);
    );
}

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSController")]
impl NSUserDefaultsController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}
