Permalink
Browse files

Fixed issue where User node wasn't being created in the XML parser,

which caused the user id to take the place of the list id and the
results to not be properly structured.
  • Loading branch information...
1 parent 0b58bc2 commit 5c01a51390b72856d2a19eac809aa41cc84d1594 @catsby catsby committed with alexrepty Aug 12, 2010
Showing with 9 additions and 2 deletions.
  1. +9 −2 MGTwitterUserListsParser.m
View
11 MGTwitterUserListsParser.m
@@ -26,6 +26,11 @@ - (void)parser:(NSXMLParser *)theParser didStartElement:(NSString *)elementName
NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
[parsedObjects addObject:newNode];
currentNode = newNode;
+ } else if ([elementName isEqualToString:@"user"]) {
+ // Add a 'user' dictionary to current node.
+ NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
+ [currentNode setObject:newNode forKey:elementName];
+ currentNode = newNode;
} else if (currentNode) {
// Create relevant name-value pair.
[currentNode setObject:[NSMutableString string] forKey:elementName];
@@ -36,8 +41,10 @@ - (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:@"user"]) {
+
+ if ([elementName isEqualToString:@"list"]) {
+ currentNode = [parsedObjects lastObject];
+ } else if ([elementName isEqualToString:@"user"]) {
[self addSource];
currentNode = nil;
}

0 comments on commit 5c01a51

Please sign in to comment.