Person 类
#import <Foundation/Foundation.h>
#import "Computer.h"
@interface Person : NSObject
+(void)playGames:(Computer *)computer;
@end
#import "Person.h"
@implementation Person
+(void)playGames:(Computer *)computer{
[computer playGames];
}
@end
Computer 类
#import <Foundation/Foundation.h>
@interface Computer : NSObject
-(void)playGames;
@end
#import "Computer.h"
@implementation Computer
-(void)playGames{
NSLog(@"开始玩游戏");
}
@end
#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Computer *cpu = [Computer new];
[Person playGames:cpu];
}
return 0;
}
|
|