Notification CENTER-Nsnotificationcenter

Source: Internet
Author: User
Tags notification center

---restore content starts---

Ns_assume_nonnull_begin

/**************** Notifications ****************/

The notice, which is sent, is received.

@interface nsnotification: nsobject <nscopying, nscoding>

Name of the notice

@property (readonly, copy) nsstring *name;

A specific object.

@property (nullable, readonly, retain) ID object;

Parameter information

@property (nullable, readonly, copy) nsdictionary *userinfo;

Initialize a Notification object

Name in the future who will accept, (send to whom)

Object specific to one of the objects, or nil,

UserInfo additional information, parameters

-(instancetypensstring *) Name object: (nullable id) object UserInfo: (nullable nsdictionary *) UserInfo ns_available (10_6, 4_0) ns_designated_ Initializer

-(nullable instancetype) Initwithcoder: (nscoder *) Adecoder Ns_designated_initializer ;

@end

@interface nsnotification (nsnotificationcreation)

Initialize a notification

+ (instancetype) Notificationwithname: (nsstring *) AName object: (nullable ID) AnObject;

Ditto

+ (instancetype) Notificationwithname: (nsstring *) AName object: (nullable ID ) AnObject UserInfo: (nullable nsdictionary *) auserinfo;

-(instancetype) init /*ns_unavailable*/; /* do not invoke; not a valid initializer to this class * /

@end

/**************** Notification Center ****************/

@interface nsnotificationcenter: nsobject {

@package

void * __strong _impl;

void * __strong _callback;

void *_pad[);

}

Simple interest, get notification hubs, register, or send notifications. Must be first registered, sent after. Otherwise, it is invalid.

+ (nsnotificationcenter *) defaultcenter;

Registration notification, (monitoring notification)

-(void) Addobserver: (ID) Observer selector: (SEL) aselector name: (nullable NSString *) AName object: (nullable ID) anobject;

Send Notifications

-(void) Postnotification: (nsnotification *) notification;

-(void) Postnotificationname: (nsstring *) AName object: (nullable ID) anobject;

-(void) Postnotificationname: (nsstring *) AName object: (nullable ID) AnObject UserInfo: (nullable nsdictionary *) auserinfo;

Remove notifications

-(void) Removeobserver: (ID) observer;

-(void) Removeobserver: (ID) Observer name: (nullable nsstring *) AName object: ( nullable ID) anobject;

-(id <nsobject >) Addobserverforname: (nullable NSString< Span class= "S1" > *) Name object: (nullable id) Obj queue: (nullable nsoperationqueue *) queue Usingblock: (void (^) (nsnotification *note)) Block ns_available (10_6, 4< Span class= "S1" >_0)

//The return value is retained by the system, and should was held onto by the caller in

//order to remove the observer with Removeobserver:later and to stop observation.

@end

Ns_assume_nonnull_end

---restore content ends---

Notification CENTER-Nsnotificationcenter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.