use crate::common::*;
use crate::Foundation::*;
typed_extensible_enum!(
pub type NSNotificationName = NSString;
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "Foundation_NSNotification")]
pub struct NSNotification;
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl ClassType for NSNotification {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl NSCoding for NSNotification {}
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl NSCopying for NSNotification {}
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl NSObjectProtocol for NSNotification {}
extern_methods!(
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl NSNotification {
#[method_id(@__retain_semantics Other name)]
pub unsafe fn name(&self) -> Id<NSNotificationName>;
#[method_id(@__retain_semantics Other object)]
pub unsafe fn object(&self) -> Option<Id<AnyObject>>;
#[cfg(feature = "Foundation_NSDictionary")]
#[method_id(@__retain_semantics Other userInfo)]
pub unsafe fn userInfo(&self) -> Option<Id<NSDictionary>>;
#[cfg(feature = "Foundation_NSDictionary")]
#[method_id(@__retain_semantics Init initWithName:object:userInfo:)]
pub unsafe fn initWithName_object_userInfo(
this: Allocated<Self>,
name: &NSNotificationName,
object: Option<&AnyObject>,
user_info: Option<&NSDictionary>,
) -> Id<Self>;
#[cfg(feature = "Foundation_NSCoder")]
#[method_id(@__retain_semantics Init initWithCoder:)]
pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
}
);
extern_methods!(
#[cfg(feature = "Foundation_NSNotification")]
unsafe impl NSNotification {
#[method_id(@__retain_semantics Other notificationWithName:object:)]
pub unsafe fn notificationWithName_object(
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
) -> Id<Self>;
#[cfg(feature = "Foundation_NSDictionary")]
#[method_id(@__retain_semantics Other notificationWithName:object:userInfo:)]
pub unsafe fn notificationWithName_object_userInfo(
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
a_user_info: Option<&NSDictionary>,
) -> Id<Self>;
}
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "Foundation_NSNotificationCenter")]
pub struct NSNotificationCenter;
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl ClassType for NSNotificationCenter {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl Send for NSNotificationCenter {}
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl Sync for NSNotificationCenter {}
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl NSObjectProtocol for NSNotificationCenter {}
extern_methods!(
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl NSNotificationCenter {
#[method_id(@__retain_semantics Other defaultCenter)]
pub unsafe fn defaultCenter() -> Id<NSNotificationCenter>;
#[method(addObserver:selector:name:object:)]
pub unsafe fn addObserver_selector_name_object(
&self,
observer: &AnyObject,
a_selector: Sel,
a_name: Option<&NSNotificationName>,
an_object: Option<&AnyObject>,
);
#[cfg(feature = "Foundation_NSNotification")]
#[method(postNotification:)]
pub unsafe fn postNotification(&self, notification: &NSNotification);
#[method(postNotificationName:object:)]
pub unsafe fn postNotificationName_object(
&self,
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
);
#[cfg(feature = "Foundation_NSDictionary")]
#[method(postNotificationName:object:userInfo:)]
pub unsafe fn postNotificationName_object_userInfo(
&self,
a_name: &NSNotificationName,
an_object: Option<&AnyObject>,
a_user_info: Option<&NSDictionary>,
);
#[method(removeObserver:)]
pub unsafe fn removeObserver(&self, observer: &AnyObject);
#[method(removeObserver:name:object:)]
pub unsafe fn removeObserver_name_object(
&self,
observer: &AnyObject,
a_name: Option<&NSNotificationName>,
an_object: Option<&AnyObject>,
);
#[cfg(all(
feature = "Foundation_NSNotification",
feature = "Foundation_NSOperationQueue"
))]
#[method_id(@__retain_semantics Other addObserverForName:object:queue:usingBlock:)]
pub unsafe fn addObserverForName_object_queue_usingBlock(
&self,
name: Option<&NSNotificationName>,
obj: Option<&AnyObject>,
queue: Option<&NSOperationQueue>,
block: &Block<(NonNull<NSNotification>,), ()>,
) -> Id<NSObject>;
}
);
extern_methods!(
#[cfg(feature = "Foundation_NSNotificationCenter")]
unsafe impl NSNotificationCenter {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);