#import <Foundation/Foundation.h>
@interface Person : NSObject
@property (nonatomic,copy) NSString *firstName;
@property (nonatomic,copy) NSString *lastName;
@end
#import "Person.h"
@implementation Person
@end
当我们在实际工作中,可能需要创建一个名为Student的新类,然后在Person的类中应该有一个Student的属性,一般做法是引入在Person.h文件中引入Student.h
#import <Foundation/Foundation.h>
#import "Student.h"
@interface Person : NSObject
@property (nonatomic,copy) NSString *firstName;
@property (nonatomic,copy) NSString *lastName;
@property (nonatomic,strong) Student *stu;
@end
#import "Person.h"
@implementation Person
@end
#import <Foundation/Foundation.h>
@class Student;
@interface Person : NSObject
@property (nonatomic,copy) NSString *firstName;
@property (nonatomic,copy) NSString *lastName;
@property (nonatomic,strong) Student *stu;
@end
#import "Person.h"
#import "Student.h"
@implementation Person
@end
如果你写的类, 集成某个类, 则必须引入定义那个父类的头文件,或者是你声明的类遵从某个协议, 那么该协议必须有完整定义, 而且不能用向前声明, 向前声明只能告诉编译器有某个协议, 而此时编译器却需要知道该协议中定义的方法
Effective+Objective-C 2.0 编写高质量iOS与OS X代码的52个有效方法