在一些苹果iPhone的示例中,有些属性在头文件中声明,而有些在实现文件中声明。例如,在Seismic XML示例中:
ParseOperation.h
在实现文件中,额外接口声明的作用是什么?
ParseOperation.h
@interface ParseOperation : NSOperation {
NSData *earthquakeData;
@private
NSDateFormatter *dateFormatter;
// these variables are used during parsing
Earthquake *currentEarthquakeObject;
Contact *currentContactObject;
NSMutableArray *currentParseBatch;
NSMutableString *currentParsedCharacterData;
BOOL accumulatingParsedCharacterData;
BOOL didAbortParsing;
NSUInteger parsedEarthquakesCounter;
}
@property (copy, readonly) NSData *earthquakeData;
@end
ParseOperation.m
@interface ParseOperation () <NSXMLParserDelegate>
@property (nonatomic, retain) Earthquake *currentEarthquakeObject;
@property (nonatomic, retain) NSMutableArray *currentParseBatch;
@property (nonatomic, retain) NSMutableString *currentParsedCharacterData;
@property (nonatomic, retain) Contact *currentContactObject;
@end
在实现文件中,额外接口声明的作用是什么?