A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© Storm_ 中级黑马   /  2015-11-12 10:48  /  747 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

#import <Foundation/Foundation.h>
@class Student;

@protocol findHouseProtocol <NSObject>
-(void)findHouse:(Student*)stu;
@end
#import <Foundation/Foundation.h>
#import "findHouseProtocol.h"

@interface LinkHouse : NSObject<findHouseProtocol>


@end
#import "LinkHouse.h"

@implementation LinkHouse
-(void)findHouse:(Student *)stu{
    NSLog(@"帮%@找房子",stu);
}
@end

#import <Foundation/Foundation.h>
#import "findHouseProtocol.h"

@interface Student : NSObject
@property(nonatomic,strong)id<findHouseProtocol>delegate;
-(void)needHouse;
@end

#import "Student.h"

@implementation Student
-(void)needHouse{
    NSLog(@"需要房子");
    [self.delegate findHouse:self];
}
@end

#import <Foundation/Foundation.h>
#import "Student.h"
#import "LinkHouse.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        Student *s = [Student new];
        LinkHouse *lk=[LinkHouse new];
        
        s.delegate = lk;
        [s needHouse];
        
        
    }
    return 0;
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马