main.m文件
#import <foundation/foundation.h> #import "person.h" int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... person *xw = [person new]; [xw needhouse:@"小区房"]; } return 0; }
agent.h
#import <foundation/foundation.h> @protocol renthousedelegate<nsobject> - (void) renthousedidfinished:(nsstring *)result; @end @interface agent : nsobject @property (nonatomic,assign) id <renthousedelegate>delegate; - (nsstring *)renthouse; @end
agent.m
#import "agent.h" @implementation agent - (nsstring *)renthouse{ if (self.delegate != nil) { nsstring *result = @"房子找到了,为**小区3栋405"; [self.delegate renthousedidfinished:result]; return result; } return nil; } @end
person.h
#import <foundation/foundation.h> #import "agent.h" @interface person : nsobject<renthousedelegate> - (void) needhouse:(nsstring *)require; @end
person.m
#import "person.h" @implementation person - (void)needhouse:(nsstring *)require{ //1.找到中介(需要导入中介类) agent *agent = [agent new]; //2.告诉中介我是谁,(在这里就需要在中介类定义一个属性进行记录) agent.delegate = self; //3.中介去租房子,(在这里需要在中介类里面定义一个租房子的方法) [agent renthouse]; } - (void)renthousedidfinished:(nsstring *)result{ nslog(@"%@",result); } @end
如对本文有疑问, 点击进行留言回复!!
Codeforces Round #657 (Div. 2) C题
hdu2222 Keywords Search(ac自动机模板-kuangbin)
网友评论