I’ve just finished my Objective C class that is used as an NSXMLParser delegate. It contains a couple of parser: methods that NSXMLParserDelegate should implement and also my own parserOutput property and a new method called initWithEncryptedFile:.
Now, do I need to have those parser: methods in my .h file as well? Or is it enough to put there what’s not described in NSXMLParserDelegate‘s documentation?
Is it enough to write .h like this:
#import <Foundation/Foundation.h>
@interface DataFileParser : NSXMLParser <NSXMLParserDelegate>
@property (strong, nonatomic) NSMutableOrderedSet *parserOutput;
- (id) initWithEncryptedFile:(NSString *)path;
@end
Or should I mention also all parser: methods like this:
#import <Foundation/Foundation.h>
@interface DataFileParser : NSXMLParser <NSXMLParserDelegate>
@property (strong, nonatomic) NSMutableOrderedSet *parserOutput;
- (id) initWithEncryptedFile:(NSString *)path;
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)elementValue;
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;
@end
Both versions work.
The first version is fine since you’re declaring the
DataFileParserconforms to that protocol.