Basic concept of oc8_ Agent

Source: Internet
Author: User

////ProtectedDelegate.h//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>@protocolProtecteddelegate <nsobject>-(void) bark;@end////Person.h//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>#import "ProtectedDelegate.h"@interfaceperson:nsobject{ID<ProtectedDelegate>_delegate;}//object pointers are also subject to protocol@property (Retain, nonatomic)ID<ProtectedDelegate>Delegate;- (void) go;@end////person.m//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import "Person.h"@implementation Person- (void) go{[_delegate bark];}@end////Cat.h//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>#import "ProtectedDelegate.h"//Include header file@interfaceCat:nsobject <protecteddelegate>//abide by this Agreement@end////CAT.M//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import "Cat.h"@implementationCat- (void) bark{NSLog (@"Miao Miao Miao ...");}@end////Dog.h//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>#import "ProtectedDelegate.h"@interfaceDog:nsobject <ProtectedDelegate>@end////DOG.M//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import "Dog.h"@implementationDog- (void) bark{NSLog (@" Wang Wang Wang ...");}@end////main.m//Basic concept of oc8_ agent////Created by zhangxueming on 15/6/24.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>#import "Dog.h"#import "Cat.h"#import "Person.h"intMainintargcConst Char*argv[]) {@autoreleasepool { person*xiaoxin =[[Person alloc] init]; Dog*dog =[[Dog alloc] init]; Xiaoxin.Delegate=Dog;        [Xiaoxin go]; Cat*cat =[[Cat alloc] init]; Xiaoxin.Delegate=Cat;    [Xiaoxin go]; }    return 0;}

Basic concept of oc8_ Agent

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.