-
Notifications
You must be signed in to change notification settings - Fork 164
/
MGTwitterMiscParser.m
48 lines (34 loc) · 1.35 KB
/
MGTwitterMiscParser.m
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
//
// MGTwitterMiscParser.m
// MGTwitterEngine
//
// Created by Matt Gemmell on 06/06/2008.
// Copyright 2008 Instinctive Code. All rights reserved.
//
#import "MGTwitterMiscParser.h"
@implementation MGTwitterMiscParser
#pragma mark NSXMLParser delegate methods
- (void)parser:(NSXMLParser *)theParser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
//NSLog(@"Started element: %@ (%@)", elementName, attributeDict);
[self setLastOpenedElement:elementName];
if (!currentNode) {
NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
[parsedObjects addObject:newNode];
currentNode = newNode;
}
// Create relevant name-value pair.
[currentNode setObject:[NSMutableString string] forKey:elementName];
}
- (void)parser:(NSXMLParser *)theParser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
[super parser:theParser didEndElement:elementName namespaceURI:namespaceURI qualifiedName:qName];
if ([elementName isEqualToString:@"remaining_hits"]) {
NSNumber *hits = [NSNumber numberWithInt:[[currentNode objectForKey:elementName] intValue]];
[currentNode setObject:hits forKey:elementName];
}
}
@end