// // XMLParser.h // acidcow // // Created by Matthew Handler on 4/15/11. // Copyright 2011 Earl Industries. All rights reserved. // #import //typedef enum { // XMLParserTypeAbstract = -1, // XMLParserTypeNSXMLParser = 0, // XMLParserTypeLibXMLParser //} XMLParserType; @class XMLParser, Topic; @protocol XMLParserDelegate @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 delegate; NSMutableArray *parsedTopics; } @property (nonatomic, assign) id 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