diff options
Diffstat (limited to 'Classes/XMLParser.h')
-rw-r--r-- | Classes/XMLParser.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Classes/XMLParser.h b/Classes/XMLParser.h new file mode 100644 index 0000000..d919ba2 --- /dev/null +++ b/Classes/XMLParser.h @@ -0,0 +1,59 @@ +// +// XMLParser.h +// acidcow +// +// Created by Matthew Handler on 4/15/11. +// Copyright 2011 Earl Industries. All rights reserved. +// + +#import <UIKit/UIKit.h> + +//typedef enum { +// XMLParserTypeAbstract = -1, +// XMLParserTypeNSXMLParser = 0, +// XMLParserTypeLibXMLParser +//} XMLParserType; + +@class XMLParser, Topic; + +@protocol XMLParserDelegate <NSObject> + +@optional +// Called by the parser when parsing is finished. +- (void)parserDidEndParsingData:(XMLParser *)parser; +// Called by the parser in the case of an error. +- (void)parser:(XMLParser *)parser didFailWithError:(NSError *)error; +// Called by the parser when one or more songs have been parsed. This method may be called multiple times. +- (void)parser:(XMLParser *)parser didParseTopics:(NSArray *)parsedTopics; + +@end + +@interface XMLParser : NSObject { + id <XMLParserDelegate> delegate; + NSMutableArray *parsedTopics; +} + +@property (nonatomic, assign) id <XMLParserDelegate> delegate; +@property (nonatomic, retain) NSMutableArray *parsedTopics; + +//+ (NSString *)parserName; +//+ (XMLParserType)parserType; + +- (void)start; + +// Subclasses must implement this method. It will be invoked on a secondary thread to keep the application responsive. +// Although NSURLConnection is inherently asynchronous, the parsing can be quite CPU intensive on the device, so +// the user interface can be kept responsive by moving that work off the main thread. This does create additional +// complexity, as any code which interacts with the UI must then do so in a thread-safe manner. +- (void)downloadAndParse:(NSURL *)url; + +// Subclasses should invoke these methods and let the superclass manage communication with the delegate. +// Each of these methods must be invoked on the main thread. +- (void)downloadStarted; +- (void)downloadEnded; +- (void)parseEnded; +- (void)parsedTopic:(Topic *)topic; +- (void)parseError:(NSError *)error; +//- (void)addToParseDuration:(NSNumber *)duration; + +@end |