Notice of Object-c

Source: Internet
Author: User

If the student does not come to class, the teacher sends a notice to the parents

1 #import "Parents.h"2 //#import "Teacher.h"3 @implementationParents4 5-(instancetype) init6 {7Self =[Super init];8     if(self) {9         //Registration NoticeTen         //Addobserver: The Observer, where the notice is received, One         //Selsctor: The method by which the response is notified, is a selector that specifies a method to receive the specified notification A         //Name: The name of the response, which is the name of the notification, may be received only if it matches the notification name of the notification hub -         //object: Pass parameter who goes to respond to an event when object is nil in addition to itself, all notifications named Isattenclass can receive notifications -[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (attendclass:) Name:@"Isattendclass" Object: nil]; the     } -     returnSelf ; - } -  +- (void) Attendclass: (Nsnotification *) Notification - { +     //Teacher *teacher = notification.object; ANSLog (@"Trigger Notification"); atNSLog (@"Hello parents,%@.", [notification UserInfo]); - } -  -  -  -- (void) Dealloc in { -     //remove a specified notification to[[Nsnotificationcenter Defaultcenter] removeobserver:self name:@"Isattendclass" Object: nil]; +      -     //Remove all Notifications the [[Nsnotificationcenter Defaultcenter] removeobserver:self]; * } $ Panax Notoginseng @end

1 #import<Foundation/Foundation.h>2 3 #import "Parents.h"4 5 @interfaceTeacher:nsobject6 7 @property (nonatomic,assign) BOOL Isattendclass;8 9- (void) postnotification;Ten  One @end A  -  -  the  -  -  -  +  -  +  A #import "Teacher.h" at  - @implementationTeacher -  -  -- (void) Postnotification - { inParents *parents =[[Parents alloc]init]; -_isattendclass =NO; to      +     //Send Notifications -     //object: Send notification to who the     if(!_isattendclass) { *[[Nsnotificationcenter Defaultcenter]postnotificationname:@"Isattendclass" Object:p arents userinfo:@{@"Notice":@"The kid didn't come to class."}]; $     }Panax Notoginseng } -  the @end

Notice of Object-c

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.