黑马程序员技术交流社区
标题:
oc中对象的依赖关系
[打印本页]
作者:
ncrbot
时间:
2015-11-5 21:42
标题:
oc中对象的依赖关系
#import <Foundation/Foundation.h>
#import "Student.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Student *ncr=[Student new];
Computer *com=[Computer new];
[ncr playGame:com];
}
return 0;
}
#import <Foundation/Foundation.h>
#import "Computer.h"
@interface Student : NSObject
-(void)playGame:(Computer *)com;
@end
#import <Foundation/Foundation.h>
@interface Computer : NSObject
-(void)game;
@end
#import "Computer.h"
@implementation Computer
-(void)game{
NSLog(@"ncr已经超越神的杀戮了!!");
}
@end
#import "Student.h"
@implementation Student
-(void)playGame:(Computer *)com{
[com game];
}
@end
作者:
nebouxii
时间:
2015-11-5 23:32
顶顶顶~~
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2