blob: d919ba28288e6856abf799d07e99ec8975de656f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
|