Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 99 lines (83 sloc) 1.62 kb
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
1 //
2 // MGTwitterUsersYAJLParser.m
3 // MGTwitterEngine
4 //
5 // Created by Matt Gemmell on 11/02/2008.
6 // Copyright 2008 Instinctive Code.
7 //
8
9 #import "MGTwitterUsersYAJLParser.h"
10
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
11 #define DEBUG_PARSING 0
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
12
13 @implementation MGTwitterUsersYAJLParser
14
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
15 - (void)addValue:(id)value forKey:(NSString *)key
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
16 {
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
17 if (_status)
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
18 {
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
19 [_status setObject:value forKey:key];
20 #if DEBUG_PARSING
21 NSLog(@"user: status: %@ = %@ (%@)", key, value, NSStringFromClass([value class]));
22 #endif
23 }
24 else if (_user)
25 {
26 [_user setObject:value forKey:key];
27 #if DEBUG_PARSING
28 NSLog(@"user: user: %@ = %@ (%@)", key, value, NSStringFromClass([value class]));
29 #endif
30 }
31 }
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
32
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
33 - (void)startDictionaryWithKey:(NSString *)key
34 {
35 #if DEBUG_PARSING
36 NSLog(@"user: dictionary start = %@", key);
37 #endif
38
39 if (! _user)
40 {
41 _user = [[NSMutableDictionary alloc] initWithCapacity:0];
42 }
43 else
44 {
45 if (! _status)
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
46 {
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
47 _status = [[NSMutableDictionary alloc] initWithCapacity:0];
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
48 }
49 }
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
50 }
51
52 - (void)endDictionary
53 {
54 if (_status)
55 {
56 [_user setObject:_status forKey:@"status"];
57 [_status release];
58 _status = nil;
59 }
60 else
61 {
62 [_user setObject:[NSNumber numberWithInt:requestType] forKey:TWITTER_SOURCE_REQUEST_TYPE];
63
fd65d2c Added delegate callback for each parsed object.
Craig Hockenberry authored
64 [self _parsedObject:_user];
65
ff9733a Finished parsing code with YAJL: status, message, user and misc result s...
Craig Hockenberry authored
66 [parsedObjects addObject:_user];
67 [_user release];
68 _user = nil;
69 }
70
71 #if DEBUG_PARSING
72 NSLog(@"user: dictionary end");
73 #endif
74 }
75
76 - (void)startArrayWithKey:(NSString *)key
77 {
78 #if DEBUG_PARSING
79 NSLog(@"user: array start = %@", key);
80 #endif
81 }
82
83 - (void)endArray
84 {
85 #if DEBUG_PARSING
86 NSLog(@"user: array end");
87 #endif
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
88 }
89
c8ba147 Removed -getFollowedTimelineFor:* methods since they are no longer suppo...
Craig Hockenberry authored
90 - (void)dealloc
91 {
92 [_user release];
93 [_status release];
94
95 [super dealloc];
96 }
97
fbfc444 First pass at adding JSON support with YAJL.
Craig Hockenberry authored
98 @end
Something went wrong with that request. Please try again.