Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (43 sloc) 1.899 kb
96b2053 @mattgemmell MGTwitterEngine re-import.
authored
1 //
2 // MGTwitterMessagesParser.m
3 // MGTwitterEngine
4 //
5 // Created by Matt Gemmell on 19/02/2008.
6 // Copyright 2008 Instinctive Code.
7 //
8
9 #import "MGTwitterMessagesParser.h"
10
11
12 @implementation MGTwitterMessagesParser
13
14
15 #pragma mark NSXMLParser delegate methods
16
17
18 - (void)parser:(NSXMLParser *)theParser didStartElement:(NSString *)elementName
19 namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
20 attributes:(NSDictionary *)attributeDict
21 {
22 //NSLog(@"Started element: %@ (%@)", elementName, attributeDict);
23 [self setLastOpenedElement:elementName];
24
25 if ([elementName isEqualToString:@"direct_message"]) {
26 // Make new entry in parsedObjects.
27 NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
28 [parsedObjects addObject:newNode];
29 currentNode = newNode;
30 } else if ([elementName isEqualToString:@"sender"] || [elementName isEqualToString:@"recipient"]) {
31 // Add an appropriate dictionary to current node.
32 NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
33 [currentNode setObject:newNode forKey:elementName];
34 currentNode = newNode;
35 } else if (currentNode) {
36 // Create relevant name-value pair.
37 [currentNode setObject:[NSMutableString string] forKey:elementName];
38 }
39 }
40
41
42 - (void)parser:(NSXMLParser *)theParser didEndElement:(NSString *)elementName
43 namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
44 {
45 [super parser:theParser didEndElement:elementName namespaceURI:namespaceURI qualifiedName:qName];
46
47 if ([elementName isEqualToString:@"sender"] || [elementName isEqualToString:@"recipient"]) {
48 currentNode = [parsedObjects lastObject];
49 } else if ([elementName isEqualToString:@"direct_message"]) {
50 [self addSource];
51 currentNode = nil;
52 }
53 }
54
55
56 @end
Something went wrong with that request. Please try again.